Hey guys,
What''s the best practices for overriding default Rails methods? I
can''t
seem to find a guide on this topic anywhere online.
Here''s the deal - I want to override the request_forgery_protection for
forms because we don''t set session_ids for bots, and they are now
generating exceptions.
I have created a file called
''override_request_forgery_protection.rb'',
put it in /lib, and added to application.rb the line:
require ''override_request_forgery_protection.rb''
Now in the file I have put in the following code:
module ActionController::RequestForgeryProtection
def self.included(base)
base.class_eval do
alias_method_chain authenticity_token_from_session_id, :session_check
end
base.extend(ClassMethods)
end
module ClassMethods
def authenticity_token_from_session_id_with_session_check
if defined? session.session_id # We have the session ID - behave
as rails normally would
authenticity_token_from_session_id_with_session_check
else # We don''t have a session ID, instead of croaking, lets
just
say the authenticity token is bad
return false
end
end
end
end
However, this code doesn''t seem to be being executed. I am setting
breakpoints in eclipse, and they''re not being hit. Any ideas please?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---