[Rails] Re: nil object - can anyone help?
Are you defining @user in application_controller.rb? I don't see it
defined anywhere in the code you posted. If you're using an
authentication plugin, you probably want to do something like:
@user = current_user
Even then, you'll have to check to see if current_user is nil, unless
that page is only visible to logged in users. You can do this with
something like:
<% if @user && @user.invitation_limit > 0 %>
Also, in your create method you'll want to do something like:
@invitation.sender = @user
or
@invitation.sender = current_user
Jarin Udom
Robot Mode LLC
http://robotmo.de
On Feb 10, 2:10 pm, RubyonRails_newbie <craigwest...@googlemail.com>
wrote:
> Yeah - I have @ user defined in the view and the controller....
>
> On 10 Feb, 22:01, Steve Klabnik <steve.klab...@gmail.com> wrote:
>
>
>
> > considering it's user.invitation_limit, (or maybe @user), that means you
> > need to define one or the other.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home