Quoting Frederick Cheung <frederick.cheung@gmail.com>:
Hi all. I'm getting the following error in my app:
undefined method `redirect_to' for ActionController::Base:Class
create do
ActionController::Base.redirect_to :back
end
and getting:
undefined method `redirect_to' for
#<ResourceController::FailableActionOptions:0x4b05b90>
What am I doing wrong? According to api.rubyonrails.com, redirect_to
belongs to ActionController::Base [1]
It is, but it's an instance method, and you're calling it as if it was
a class method.
Just redirect_to :back should do the trick.
I get the same error if I try just redirect_to :back.
I was thinking that could be anything to do with plugin, but it inherits from ApplicationController.
Any other tip?
My controller:
[code]
class CommentsController < ResourceController::Base
belongs_to :post, :article, :photo
create do
redirect_to :back
end
end
[/code]
[output]
undefined method `redirect_to' for #<ResourceController::FailableActionOptions:0x4b680d8>
[/output]
Quoting Frederick Cheung <frederick.cheung@gmail.com>:
Hi all. I'm getting the following error in my app:
undefined method `redirect_to' for ActionController::Base:Class
create do
ActionController::Base.redirect_to :back
end
and getting:
undefined method `redirect_to' for
#<ResourceController::FailableActionOptions:0x4b05b90>
What am I doing wrong? According to api.rubyonrails.com, redirect_to
belongs to ActionController::Base [1]
It is, but it's an instance method, and you're calling it as if it was
a class method.
Just redirect_to :back should do the trick.
I get the same error if I try just redirect_to :back.
I was thinking that could be anything to do with plugin, but it
inherits from ApplicationController.
Any other tip?
[...]
Googling for "redirect_to resource_controller" (instead "undefined bla-bla-bla"), I was sent to this thread: