Undefined method `redirect_to'

Hi all. I’m getting the following error in my app:

undefined method `redirect_to’ for ActionController::Base:Class

I’m using Windows 2000, Rails 2.0.2 and resource_controller (from
James Golick).

My controller:

class CommentsController < ApplicationController
include ResourceController::Controller

belongs_to :post, :article, :photo

create do
ActionController::Base.redirect_to :back
end
end

I’ve been also trying to use the following:

class CommentsController < ResourceController::Base
belongs_to :post, :article, :photo

create do
ActionController::Base.redirect_to :back
end
end

and

class CommentsController < ApplicationController
resource_controller

belongs_to :post, :article, :photo

create do
ActionController::Base.redirect_to :back
end
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]

Any guess?

Thanks,

davi vidal

[1] -
http://api.rubyonrails.com/classes/ActionController/Base.html#M000456

On 16 Mar 2008, at 19:20, [email protected] wrote:

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.

Fred

Quoting Frederick C. [email protected]:

end
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:

class CommentsController < ResourceController::Base
   belongs_to :post, :article, :photo

   create do
     redirect_to :back
   end
end

[output]
undefined method `redirect_to’ for
#ResourceController::FailableActionOptions:0x4b680d8
[/output]

Thank you a lot,

davi vidal

Quoting [email protected]:

create do

[…]

Googling for “redirect_to resource_controller” (instead “undefined
bla-bla-bla”), I was sent to this thread:

http://groups.google.com/group/resource_controller/browse_thread/thread/b4657a4109d6eccd

And solved my problem using:

create do
   wants.html { redirect_to :back }
end

Thank you for your attention.

Davi V.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs