RailsCasts Pro episodes are now free!

Learn more or hide this

Rich Kuo's Profile

GitHub User: richkuo

Comments by Rich Kuo

Avatar

actually i cannot find a solution for this in the link i sent. have you solved it?

Avatar

it basically 'overlooks' the validation you have in your user model

Avatar

Thank you Alain. I had nested resources with comments for both resources, and this worked for me.

for example:

ruby
resources :events do
  resources :comments
  resources :pictures do
    :comments
  end
end
ruby
def load_commentable
  if params[:picture_id]
    @commentable = Picture.find(params[:picture_id])
  elsif params[:event_id]
    @commentable = Event.find(params[:event_id])
  end
end

Order from deepest nested resource down.