redirect_to is undefined












0















I'm trying to use a redirect_to in my controller and I'm getting an error complaining that redirect_to is not defined (please see logs below)




=> Booting Puma

=> Rails 5.2.1 application starting in development

=> Run rails server -h for more startup options Puma starting in single mode...

* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas

* Min threads: 5, max threads: 5

* Environment: development

* Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop Started GET "/checkout" for 127.0.0.1 at 2018-11-22 13:18:56 -0800 (0.1ms)

SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY

"schema_migrations"."version" ASC ↳

/var/lib/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98

ActionController::RoutingError (undefined method `redirect_to' for
ChargesController:Class):
app/controllers/charges_controller.rb:39:in
`<class:ChargesController>' app/controllers/charges_controller.rb:3:in
`<main>'




My code is below. I'm not sure what I'm doing wrong. How do I go about debugging this? Any help would be appreciated.



class ChargesController < ApplicationController
def create
redirect_to(:controller => 'home_controller', :action => "index")
end


In my rails routes.rb I have



  get "/charge",    to: "charges#create"









share|improve this question




















  • 1





    Can you paste the full error?

    – Gavin Miller
    Nov 22 '18 at 19:03






  • 1





    And does ApplicationController inherit from ActionController::Base in your codebase?

    – Gavin Miller
    Nov 22 '18 at 19:04











  • Yes, it does inherit from Acitvation:Controller::Base

    – Houman Azemati
    Nov 22 '18 at 21:13











  • In the future full error should also include the stacktrace. Can you add that too please? :)

    – Gavin Miller
    Nov 22 '18 at 21:17






  • 1





    I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

    – Johan Wentholt
    Nov 23 '18 at 10:28


















0















I'm trying to use a redirect_to in my controller and I'm getting an error complaining that redirect_to is not defined (please see logs below)




=> Booting Puma

=> Rails 5.2.1 application starting in development

=> Run rails server -h for more startup options Puma starting in single mode...

* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas

* Min threads: 5, max threads: 5

* Environment: development

* Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop Started GET "/checkout" for 127.0.0.1 at 2018-11-22 13:18:56 -0800 (0.1ms)

SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY

"schema_migrations"."version" ASC ↳

/var/lib/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98

ActionController::RoutingError (undefined method `redirect_to' for
ChargesController:Class):
app/controllers/charges_controller.rb:39:in
`&LT;class:ChargesController>' app/controllers/charges_controller.rb:3:in
`&LT;main>'




My code is below. I'm not sure what I'm doing wrong. How do I go about debugging this? Any help would be appreciated.



class ChargesController < ApplicationController
def create
redirect_to(:controller => 'home_controller', :action => "index")
end


In my rails routes.rb I have



  get "/charge",    to: "charges#create"









share|improve this question




















  • 1





    Can you paste the full error?

    – Gavin Miller
    Nov 22 '18 at 19:03






  • 1





    And does ApplicationController inherit from ActionController::Base in your codebase?

    – Gavin Miller
    Nov 22 '18 at 19:04











  • Yes, it does inherit from Acitvation:Controller::Base

    – Houman Azemati
    Nov 22 '18 at 21:13











  • In the future full error should also include the stacktrace. Can you add that too please? :)

    – Gavin Miller
    Nov 22 '18 at 21:17






  • 1





    I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

    – Johan Wentholt
    Nov 23 '18 at 10:28
















0












0








0








I'm trying to use a redirect_to in my controller and I'm getting an error complaining that redirect_to is not defined (please see logs below)




=> Booting Puma

=> Rails 5.2.1 application starting in development

=> Run rails server -h for more startup options Puma starting in single mode...

* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas

* Min threads: 5, max threads: 5

* Environment: development

* Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop Started GET "/checkout" for 127.0.0.1 at 2018-11-22 13:18:56 -0800 (0.1ms)

SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY

"schema_migrations"."version" ASC ↳

/var/lib/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98

ActionController::RoutingError (undefined method `redirect_to' for
ChargesController:Class):
app/controllers/charges_controller.rb:39:in
`&LT;class:ChargesController>' app/controllers/charges_controller.rb:3:in
`&LT;main>'




My code is below. I'm not sure what I'm doing wrong. How do I go about debugging this? Any help would be appreciated.



class ChargesController < ApplicationController
def create
redirect_to(:controller => 'home_controller', :action => "index")
end


In my rails routes.rb I have



  get "/charge",    to: "charges#create"









share|improve this question
















I'm trying to use a redirect_to in my controller and I'm getting an error complaining that redirect_to is not defined (please see logs below)




=> Booting Puma

=> Rails 5.2.1 application starting in development

=> Run rails server -h for more startup options Puma starting in single mode...

* Version 3.12.0 (ruby 2.5.1-p57), codename: Llamas in Pajamas

* Min threads: 5, max threads: 5

* Environment: development

* Listening on tcp://0.0.0.0:3000

Use Ctrl-C to stop Started GET "/checkout" for 127.0.0.1 at 2018-11-22 13:18:56 -0800 (0.1ms)

SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY

"schema_migrations"."version" ASC ↳

/var/lib/gems/2.5.0/gems/activerecord-5.2.1/lib/active_record/log_subscriber.rb:98

ActionController::RoutingError (undefined method `redirect_to' for
ChargesController:Class):
app/controllers/charges_controller.rb:39:in
`&LT;class:ChargesController>' app/controllers/charges_controller.rb:3:in
`&LT;main>'




My code is below. I'm not sure what I'm doing wrong. How do I go about debugging this? Any help would be appreciated.



class ChargesController < ApplicationController
def create
redirect_to(:controller => 'home_controller', :action => "index")
end


In my rails routes.rb I have



  get "/charge",    to: "charges#create"






ruby-on-rails






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 10:19









Johan Wentholt

2,602718




2,602718










asked Nov 22 '18 at 18:58









Houman AzematiHouman Azemati

113




113








  • 1





    Can you paste the full error?

    – Gavin Miller
    Nov 22 '18 at 19:03






  • 1





    And does ApplicationController inherit from ActionController::Base in your codebase?

    – Gavin Miller
    Nov 22 '18 at 19:04











  • Yes, it does inherit from Acitvation:Controller::Base

    – Houman Azemati
    Nov 22 '18 at 21:13











  • In the future full error should also include the stacktrace. Can you add that too please? :)

    – Gavin Miller
    Nov 22 '18 at 21:17






  • 1





    I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

    – Johan Wentholt
    Nov 23 '18 at 10:28
















  • 1





    Can you paste the full error?

    – Gavin Miller
    Nov 22 '18 at 19:03






  • 1





    And does ApplicationController inherit from ActionController::Base in your codebase?

    – Gavin Miller
    Nov 22 '18 at 19:04











  • Yes, it does inherit from Acitvation:Controller::Base

    – Houman Azemati
    Nov 22 '18 at 21:13











  • In the future full error should also include the stacktrace. Can you add that too please? :)

    – Gavin Miller
    Nov 22 '18 at 21:17






  • 1





    I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

    – Johan Wentholt
    Nov 23 '18 at 10:28










1




1





Can you paste the full error?

– Gavin Miller
Nov 22 '18 at 19:03





Can you paste the full error?

– Gavin Miller
Nov 22 '18 at 19:03




1




1





And does ApplicationController inherit from ActionController::Base in your codebase?

– Gavin Miller
Nov 22 '18 at 19:04





And does ApplicationController inherit from ActionController::Base in your codebase?

– Gavin Miller
Nov 22 '18 at 19:04













Yes, it does inherit from Acitvation:Controller::Base

– Houman Azemati
Nov 22 '18 at 21:13





Yes, it does inherit from Acitvation:Controller::Base

– Houman Azemati
Nov 22 '18 at 21:13













In the future full error should also include the stacktrace. Can you add that too please? :)

– Gavin Miller
Nov 22 '18 at 21:17





In the future full error should also include the stacktrace. Can you add that too please? :)

– Gavin Miller
Nov 22 '18 at 21:17




1




1





I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

– Johan Wentholt
Nov 23 '18 at 10:28







I have the feeling we are still missing some context. Since the line "undefined method `redirect_to' for ChargesController:Class" suggests that you're trying to call redirect_to in class context (eg. in a class method or class initialisation). The stack also points to the ChargesController line 3, but only after pointing to line 39. By default controller classes don't have access to these methods, only instances of controllers can access redirect_to.

– Johan Wentholt
Nov 23 '18 at 10:28














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436788%2fredirect-to-is-undefined%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53436788%2fredirect-to-is-undefined%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin