Hi, I'm learning Rails and saw a strang thing for me.
Yesterday, I was told by my friend that there is a method named
'redirect_to'. He showed how to use the method like this:
redirect_to :back
So, I wanted to find an Api document of the method on the internet,
and tried to know which class or module owns it at first...
----------------------
$ rails console
irb(main)001:0> controller = ActionController::Base.new
=> #<ActionController::Base:0x00000004561ab8 @_routes=nil,
@_action_has_layout=true, @_headers={"Content-Type"=>"text/html"},
@_status=200, @_request=nil, @_response=nil>
irb(main):003:0> controller.method(:redirect_to).owner
=> ActionController::Instrumentation
-------------------------
So I searched 'redirect_to' at http://api.rubyonrails.org/ by using
keyword "ActionController::Instrumentation".
But the document says almost nothing but just the method signeture and
its source code.
--------------------------------------
redirect_to(*args)
# File actionpack/lib/action_controller/metal/instrumentation.rb, line
58
def redirect_to(*args)
ActiveSupport::Notifications.instrument("redirect_to.action_controller")
do |payload|
result = super
payload[:status] = response.status
payload[:location] = response.location
result
end
end
-------------------------------------
I tried the same search by Google, then I found
the same name method in another module and realized that it was what my
friend told me, because it explained the meaning of 'redirect_to :back'.
http://api.rubyonrails.org/classes/ActionControlle...
But why did I fail to search such a simple thing like this?
Something must have been wrong. I'm very confused.
Was the way of checking class(or method) through irb wrong?
Please give me some advice.
Regards.
on 2013-02-01 09:42
on 2013-02-01 10:02
i guess somthing went wrong over there.. as i also just checked and got
same as expected
>> controller.method(:redirect_to).owner
=> ActionController::Base
on 2013-02-01 10:17
(2013/02/01 17:56), Shridhar Agarwal wrote: > i guess somthing went wrong over there.. as i also just checked and got > same as expected >> controller.method(:redirect_to).owner >=> ActionController::Base What!? How about the version of Ruby and Rails? ------------------- mine are as bellow.... $ rails -v Rails 3.2.8 $ ruby -v ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux] ------------------- And I checked again, but the result wan't changed. ---------------------------------- $ rails console ... ... Loading development environment (Rails 3.2.8) irb(main):001:0> controller = ActionController::Base.new => #<ActionController::Base:0x0000000460e600 @_routes=nil, @_action_has_layout=true, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=nil, @_response=nil> irb(main):002:0> controller.method(:redirect_to).owner => ActionController::Instrumentation
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.