Hello,
I was just working my way pretty carefully through the getting started
tutorial and I''ve hit an unusual snag that I can''t make any
sense of.
After adding the authenticate before filter to my posts controller I
was presented with this error message:
Routing Error
undefined method `Â Â before_filter'' for PostsController:Class
If I delete the line that contains the before_filter then everything
works as expected, minus authentication of course. The authenticate
method is this:
private
def authenticate
authenticate_or_request_with_http_basic do |user_name, password|
user_name == ''admin'' && password ==
''password''
end
end
And the before_filter line is this:
before_filter :authenticate, :except => [:index, :show]
If anybody can tell me what is going on I would be very appreciative.
The getting started tutorial that I am referring to is here:
http://guides.rubyonrails.org/getting_started.html
Thanks,
ashleigh
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
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.
On 6 January 2011 09:48, Ashleigh <labaumgardner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I was just working my way pretty carefully through the getting started > tutorial and I''ve hit an unusual snag that I can''t make any sense of. > After adding the authenticate before filter to my posts controller I > was presented with this error message: > > Routing Error > > undefined method `Â Â before_filter'' for PostsController:Class > > If I delete the line that contains the before_filter then everything > works as expected, minus authentication of course. The authenticate > method is this: > > private > > def authenticate > authenticate_or_request_with_http_basic do |user_name, password| > user_name == ''admin'' && password == ''password'' > end > end > > And the before_filter line is this: > > before_filter :authenticate, :except => [:index, :show]Perhaps you have some non-printing characters at the start of the line. What happens if you type it in again? Also check the line before. If that does not fix it show us the stack dump and the complete error message. Also the code around the error. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
As a test, I would place the before_filter in the Application Controller to ensure it''s working. If you don''t receive an error, then do as Colin suggested above. If you do, post the error as instructed above. In the test within the application controller just put: before_filter :authenticate .. and comment out the other before_filters in your other controllers. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.