C
Cris Shupp
Gurus,
I am reading the O'Reilly book "Rails: Up and Running, 2nd Edition" and
the author told me to add the following line of code:
skip_before_filter :verify_authenticity_token
as follows:
class SlidesController < ApplicationController
skip_before_filter :verify_authenticity_token
...
This stopped me dead in my tracks as I realized I had no idea what was
going on. I am using Aptana (Eclipse) and so it can tell me that
skip_before_filter is defined in the module ClassMethods. I am assuming
that somehow this method (skip_before_filter) is mixed in?
The implementation is:
def skip_before_filter(*filters)
filter_chain.skip_filter_in_chain(*filters, &:before?)
end
What is *filters? Did I miss this in my 'Learning Ruby' book?
Anyway, I guessed that I was calling the method 'skip_before_filter'
sometime during my controller's construction. So I built a toy to
validate as follows:
####################BEGIN
test.rb###############################################
module Test
def call_me
puts "Mixin called"
end
end
module Test2
def call_me
puts "second mixin called"
end
end
class Tester
include Test, Test2
#call_me() #this call fails. This blows my theory...
def initialize
super
call_me()# this call works, but how would I call the other one?
#Test2::call_me()#this call fails
puts "A tester was built"
end
end
Tester.new
########################################END test.rb###########
output is:
Mixin called
A tester was built
Thanks for your help with my questions.
Cris
I am reading the O'Reilly book "Rails: Up and Running, 2nd Edition" and
the author told me to add the following line of code:
skip_before_filter :verify_authenticity_token
as follows:
class SlidesController < ApplicationController
skip_before_filter :verify_authenticity_token
...
This stopped me dead in my tracks as I realized I had no idea what was
going on. I am using Aptana (Eclipse) and so it can tell me that
skip_before_filter is defined in the module ClassMethods. I am assuming
that somehow this method (skip_before_filter) is mixed in?
The implementation is:
def skip_before_filter(*filters)
filter_chain.skip_filter_in_chain(*filters, &:before?)
end
What is *filters? Did I miss this in my 'Learning Ruby' book?
Anyway, I guessed that I was calling the method 'skip_before_filter'
sometime during my controller's construction. So I built a toy to
validate as follows:
####################BEGIN
test.rb###############################################
module Test
def call_me
puts "Mixin called"
end
end
module Test2
def call_me
puts "second mixin called"
end
end
class Tester
include Test, Test2
#call_me() #this call fails. This blows my theory...
def initialize
super
call_me()# this call works, but how would I call the other one?
#Test2::call_me()#this call fails
puts "A tester was built"
end
end
Tester.new
########################################END test.rb###########
output is:
Mixin called
A tester was built
Thanks for your help with my questions.
Cris