Friday, February 06, 2009
Acts as Conference coverage on Ruby Rails Review
Posted by
Steven Pothoven
at
11:42 AM
0
comments
Links to this post
Labels: Ruby on Rails
Monday, January 26, 2009
Posted by
Steven Pothoven
at
12:15 PM
0
comments
Links to this post
Labels: Ruby on Rails
Thursday, January 08, 2009
Ruby tip to handle missing records
By default if you try to use
find(id) to fetch a record from your database and the id doesn't exist you'll get a RecordNotFound error like:
>> r = Record.find(9999)
ActiveRecord::RecordNotFound: Couldn't find Record with ID=9999
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:1383:in `find_one'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:1366:in `find_from_ids'
from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.1/lib/active_record/base.rb:541:in `find'
from (irb):3
You could wrap it with a
begin and rescue and have the rescue clause create a new record such as:
begin
r = Record.find(id)
rescue
r = Record.new
end
Or you could simply use find_by_id which will return
nil if the record is not found and re-write it as:
r = Record.find_by_id(id) || Record.new
Posted by
Steven Pothoven
at
11:47 AM
1 comments
Links to this post
Labels: Ruby on Rails
Tuesday, December 23, 2008
Merb and Rails Merge
Here is the announcement from Rails creator David Heinemeier Hansson and the similar announcement from the Merb perspective from Yehuda Katz.
Keep up with all the latest Ruby and Rails news at Ruby Rails Review.
Posted by
Steven Pothoven
at
9:26 PM
2
comments
Links to this post
Labels: Ruby on Rails
Tuesday, December 16, 2008
Ruby on Rails News Site
As he mentioned in the announcement I created a very easy to use CMS tool which allows us to drag-and-drop the news stories all over the page for placement (or addition and removal), as well as a bookmarklet to simplify the process of adding new stories. I've very happy with how it turned out, unfortunately no one gets to see it but he and I.
Posted by
Steven Pothoven
at
9:01 AM
0
comments
Links to this post
Labels: Ruby on Rails
Subscribe to:
Posts (Atom)

