This is likely a painfully newbie-ish question, so please bare with me
I’m muddling through my first rails application, and decided to use the
Login Engine to handle user authentication. Now, according to the
README, I should be able to “use current_user method provided by
UserHelper”, like so:
Welcome <%= current_user.name %>
I’ve put that line in my application.rhtml, and return the following
undefined local variable or method `current_user' for
which seems to suggest I haven’t done something correctly.
Now, I can find where current_user is set in
I’m still trying to work out what goes where in rails, but I figured in
order for the method to be available globally, I needed to move that
definition into app/controllers/application.rb. Still received the same
I then tried adding the definition for current_user to
app/helpers/application_helper.rb, and that sort of did the trick.
“Welcome <%= current_user.name %>” now translates properly in my layout.
My real goal, however, is to get usermonitor to work
and current_user still does not appear to be accessible by this module.
When I attempt to edit an object in one of my models, I get the error:
undefined method `current_user' for User:Class
So I gather app/helpers/application_helper.rb is likewise not the
correct place for this.
I then try putting it in config/environment.rb (which seems even less
likely, though at this point I do have to concede ‘what do I know?’),
which also appears to work as far as my application.rhtml is concerned.
But when I try to edit an object, I now get:
private method `current_user' called for User:Class
This feels a bit like progress, but I’m stumped regarding how to make
this method public (and whether or not that’s really what I want to do).
If I understand things correctly, methods are public by default, and
only become private when “private” is placed before their definition?
Which is fine, except that there is no instance of “private” in my
At this point, I’m stumbling blind, and don’t know if I’m even remotely
headed in the right direction. If somebody could give me a nudge in that
right direction, I would be so very grateful!
Thanks in advance,