Archive for the 'Ruby on Rails' Category

Nested Routes and Forms in Rails 2.0

Thursday, February 28th, 2008

If you’re doing a form post to a nested resource, like creating a comment under
/posts/1/comments/
with a route like
map.resources :posts do |post|
post.resources :comments
end
you have to account for that when you’re creating a form, you can’t just send it to the comment and hope everything will work out.
It took me a little […]

Destroying An Object After Touching Its Relatives

Friday, November 2nd, 2007

Just a little thought I thought I should be sure to share, as it’s something I wasn’t aware of until this morning.
If you load an object in Rails and load any of it’s relatives through acts_as_tree, and then destroy the object, it will take the relatives with it.

@person = Person.find :first

@person.children.each do |child|
[…]