If you want to install and run Ruby programs on your own computer, follow our Ruby Installation Instructions
There is no section this week. There is still a lot to learn. Interested in learning more? Check out the links below
This week, we created a very basic photo gallery. We discussed the roles that Models play and we covered how these relationships are expressed in our application. We used what we learned in previous lectures to create our applicaiton and Gallery objects. Then we determined the relationship between our Gallery objects and our soon-to-be Image objects. We used scaffolding to create our Image scaffolding such that an image belongs to a Gallery. Finally, we took advantage of the relationships between Galleries and Images to simplify our code.
There is no homework for this week, but you are encouraged to explore creating applications with relationships between objects.
You may use the photo gallery we made in the Ruby Lecture as a reference. To see it work, check out the Rails Gallery Demo. You can then inspect the application by looking in my ruby_apps folder and viewing the Rails Gallery Source Files
This week, we finished up our blog. We customized our views, removed some redundant code from our templates using partials, re-ordered our entries so the most recent one is showed first, and displayed only the 5 most recent entries. We also showed how to create a Rails app on Webster from start to finish.
The homework for this week is to create your own Ruby web application on webster. It can be anything you want, so long as it requires you to create one controller, one view, and connect to the database. You will only need to turn in a text file called app_url.txt. In this file, you must include your name and the url to a Rails app.
You do not need to use the Rails Scaffold, but you will find it very useful. Refer to the steps on slide 6 of the week 7 slides on how to create your application on webster as the setup has changed slightly. You may also use the blog we made in the Ruby Lecture as a reference. To see it work, check out the Rails Blog Demo. You can then inspect the application by looking in my ruby_apps folder and viewing the Rails Blog Source Files
This week, we showed you how to use the power of Ruby on Rails to create web appications quickly. We also showed how to get Rails applications to run on Webster. There is no homework assignment for this week.
If you would like a database account, please email me to so that we may set one up for you so that you can create Rails applications on Webster
In week 5, we introduced Ruby on Rails, the Ruby web development framework. We discussed how to create a Rails application within the framework and discussed major components. We covered the basics of the functionality of the application, creating barebones verions of a View and a Controller to display a unique homepage instead of the default "Welcome Aboard" page.
For your assignment this week, you will only need to turn in a text file called app_url.txt. In this file, you must include your name and the url to a Rails app that you created on Webster. The only thing you must do for this app is create an appropriate and unique homepage that differs from the default "Welcome Aboard" page displayed when you create a new Rails application.
UPDATE In lecture, we were unclear on how to get your Rails app to run on Webster. We will be clearing this up in the next lecture and will be extending the due date for the homework.
These are the steps necessary to create a unique home page for your web app. These steps can be done on your home machine if Rails is installed. They can also be done on Webster. The paths used in these explanations assume the applicaiton is being created on Webster.
rails my_app
map.home '/', :controller => 'home'
map.connect '', :controller => 'home'
map.home '/rctucker/my_app', :controller => 'home'
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
ruby script/server
In week 4, we covered how to create objects, including state and behavior. We also discussed inheritance and how Ruby allows us to modify the state and behavior of any class. Finally, we saw how to use objects in combination with embedded Ruby files.
UPDATE: As of April 30 at 4:45pm, the assignment has been updated. You no longer need to write the to_html function. Please refer to the write-up for the changes.
For your assignment this week, you will be writing a Badguy class for Battwitter. We will provide you with the skeleton .erb, .css, and .txt files. You are to write Badguy.rb
so that the skeleton.erb file runs to produce Battwitter. For full details on the assignment, refer to the Ruby Homework 4 Writeup.
Homework files:
In week 3 we learned how to use Ruby like we have been using PHP to create dynamic webpages by using embedded ruby (erb). We also learned how to accept query parameters and use their values in the page.
For your assignment this week, create an Embedded Ruby file called 12days.erb
. It will produce the same output as the "12 Days of Xmas" page we wrote in PHP in Section 3. Addtionally, The program should take a parameter "days" that specifies how many days to count up to. Although any integer value can be accepted, it should be bounded with a lower bound of 1 and a upper bound of 12. You can assume that a number will be passed as a parameter.
In week 2 we learned more Ruby syntax. We covered Arrays and Hashes. We also talked about blocks are and how they are used in conjunction with yield statements. Additionally, we covered what iterators are and how they can be used instead of loops, especially over Arrays, Hashes, and Strings. Finally, we demonstrated reading and writing to files.
For your assignment this week, create a Ruby file called personality.rb
that implements the CSE 142 Personality Assignment. You do not need to implement any creative output or extra credit functionality. Use syntax specific to Ruby whenever possible. Our solution does not require use of the yield statements we learned this week.
In week 1 we learned the basics of Ruby syntax. We covered input and output, variables, if-statements, loops, methods, parameters, and returns.
For your assignment this week, create a Ruby file called ascii_art.rb
that implements the CSE 142 Space Needle Assignment (Part B only) at http://www.cs.washington.edu/education/courses/cse142/08au/homework/2/spec.pdf or the CSE 142 Rocket Ship Assignment http://www.cs.washington.edu/education/courses/cse142/09wi/handouts/03.html. If you are doing the Space Needle Assignment, you only need to do Part B. Use syntax specific to Ruby whenever possible. Your solution needs to make the Space Needle scale with a constant. As a ballpark, our solution is 35 lines without comments.
This quarter in CSE 190 M, we will conduct a special optional program to offer students a chance to learn a second programming language as you're learning Java. The second language's name is Ruby.
Ruby is a language that's good for writing programs to process text and other data. It's used heavily in the Linux operating system and at companies like Google.
Ruby is used in a lot of other fields and disciplines, so it can be useful to have experience in it. Lastly, Ruby is a powerful language that does a lot of things more easily than Java, so it can be fun rewriting your past Java programs in Ruby and seeing how much shorter and cleaner they can be solved.
The work involved in this program would be the following:
Primarily, these projects will consist of solving the same problem as that week's Java programming assignment, but in Ruby, and perhaps with minor modifications to the assignment spec.
Participation is entirely optional. The reward for doing these projects will be small, to make sure that Ruby doesn't give students with prior experience an unfair advantage over new programmers. Right now, we're planning to reward students with 1 free late day for each Ruby program submitted. No grade points will be added or subtracted in any way for participating in this project.
Just look at the slides and/or links above, and if you find it interesting, try writing the Ruby program for that week. If you finish it, you can turn it in from a link that we'll put up above on this page.