On Sep 5, 10:53 pm, nobosh <[email protected]> wrote:
> Ed thanks for the reply. I'd love to hear more... I tried your
> suggestion but it error'd:
>
> "undefined method `Notes' for nil:NilClass"
>

Two possible issues:

1.  Do you have the relationship declared in the models?

class Note < ActiveRecord
  belongs_to :user
end

class User < ActiveRecord
  has_many :notes
end

2.  If @user is a nil object, it will throw an error.  Set @user to
the current_user in your before_filter.  If there is a possibility of
hitting that point with a nil user, then change the line to read
something like this:

@note = @user ? @user.notes.find(params[:id]) : nil

which is a shorter way of saying

if @user.nil?
  @note = nil
else
  @note = @user.notes.find(params[:id])
end

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to