ActionController::UrlGenerationError for devise registration controller












1















I'm running into an interesting ActionController::UrlGenerationError while testing my custom devise User::RegistrationsController



Here's the error:



 ActionController::UrlGenerationError:
No route matches {:action=>"create", :controller=>"user/registrations", :user=>{:name=>"Adriane Koepp", :city=>"Nidiafurt", :address=>"14955 Cormier Viaduct", :country=>"Mozambique", :email=>"moshe@kozey.com", :phone_primary=>"(295) 491-0447 x9108", :phone_secondary=>"536.985.9499 x7264", :postal_code=>"93438-7448", :province=>"South Carolina", :password=>"MaH9R5G8XqB", :pets_attributes=>[{:name=>"Patches", :chip_number=>"149793073311890", :species=>"iusto"}]}}


The error shows up in all my tests for this controller, but for simplicity, I'll only list one test for the create action:



it 'creates a new User' do
expect do
post :create, params: { user: valid_attributes }
end.to change(User, :count).by(1)
end


The routes.rb contains:



devise_for :users, controllers: {
registration: 'user/registration'
}


I can navigate to my registration page just fine at http://localhost:3000/users/sign_up, but for some reason, my tests don't seem to think this controller has a valid URL for the create action. Why so?



Additional steps



Upon following D1ceWard's suggestion, I pluralized "registration" in my routes, and now the error message changed to a AbstractController::ActionNotFound error. I countered that by following the documentation and added the following block to the top of my tests:



before(:each) do
@request.env['devise.mapping'] = Devise.mappings[:user]
end









share|improve this question





























    1















    I'm running into an interesting ActionController::UrlGenerationError while testing my custom devise User::RegistrationsController



    Here's the error:



     ActionController::UrlGenerationError:
    No route matches {:action=>"create", :controller=>"user/registrations", :user=>{:name=>"Adriane Koepp", :city=>"Nidiafurt", :address=>"14955 Cormier Viaduct", :country=>"Mozambique", :email=>"moshe@kozey.com", :phone_primary=>"(295) 491-0447 x9108", :phone_secondary=>"536.985.9499 x7264", :postal_code=>"93438-7448", :province=>"South Carolina", :password=>"MaH9R5G8XqB", :pets_attributes=>[{:name=>"Patches", :chip_number=>"149793073311890", :species=>"iusto"}]}}


    The error shows up in all my tests for this controller, but for simplicity, I'll only list one test for the create action:



    it 'creates a new User' do
    expect do
    post :create, params: { user: valid_attributes }
    end.to change(User, :count).by(1)
    end


    The routes.rb contains:



    devise_for :users, controllers: {
    registration: 'user/registration'
    }


    I can navigate to my registration page just fine at http://localhost:3000/users/sign_up, but for some reason, my tests don't seem to think this controller has a valid URL for the create action. Why so?



    Additional steps



    Upon following D1ceWard's suggestion, I pluralized "registration" in my routes, and now the error message changed to a AbstractController::ActionNotFound error. I countered that by following the documentation and added the following block to the top of my tests:



    before(:each) do
    @request.env['devise.mapping'] = Devise.mappings[:user]
    end









    share|improve this question



























      1












      1








      1








      I'm running into an interesting ActionController::UrlGenerationError while testing my custom devise User::RegistrationsController



      Here's the error:



       ActionController::UrlGenerationError:
      No route matches {:action=>"create", :controller=>"user/registrations", :user=>{:name=>"Adriane Koepp", :city=>"Nidiafurt", :address=>"14955 Cormier Viaduct", :country=>"Mozambique", :email=>"moshe@kozey.com", :phone_primary=>"(295) 491-0447 x9108", :phone_secondary=>"536.985.9499 x7264", :postal_code=>"93438-7448", :province=>"South Carolina", :password=>"MaH9R5G8XqB", :pets_attributes=>[{:name=>"Patches", :chip_number=>"149793073311890", :species=>"iusto"}]}}


      The error shows up in all my tests for this controller, but for simplicity, I'll only list one test for the create action:



      it 'creates a new User' do
      expect do
      post :create, params: { user: valid_attributes }
      end.to change(User, :count).by(1)
      end


      The routes.rb contains:



      devise_for :users, controllers: {
      registration: 'user/registration'
      }


      I can navigate to my registration page just fine at http://localhost:3000/users/sign_up, but for some reason, my tests don't seem to think this controller has a valid URL for the create action. Why so?



      Additional steps



      Upon following D1ceWard's suggestion, I pluralized "registration" in my routes, and now the error message changed to a AbstractController::ActionNotFound error. I countered that by following the documentation and added the following block to the top of my tests:



      before(:each) do
      @request.env['devise.mapping'] = Devise.mappings[:user]
      end









      share|improve this question
















      I'm running into an interesting ActionController::UrlGenerationError while testing my custom devise User::RegistrationsController



      Here's the error:



       ActionController::UrlGenerationError:
      No route matches {:action=>"create", :controller=>"user/registrations", :user=>{:name=>"Adriane Koepp", :city=>"Nidiafurt", :address=>"14955 Cormier Viaduct", :country=>"Mozambique", :email=>"moshe@kozey.com", :phone_primary=>"(295) 491-0447 x9108", :phone_secondary=>"536.985.9499 x7264", :postal_code=>"93438-7448", :province=>"South Carolina", :password=>"MaH9R5G8XqB", :pets_attributes=>[{:name=>"Patches", :chip_number=>"149793073311890", :species=>"iusto"}]}}


      The error shows up in all my tests for this controller, but for simplicity, I'll only list one test for the create action:



      it 'creates a new User' do
      expect do
      post :create, params: { user: valid_attributes }
      end.to change(User, :count).by(1)
      end


      The routes.rb contains:



      devise_for :users, controllers: {
      registration: 'user/registration'
      }


      I can navigate to my registration page just fine at http://localhost:3000/users/sign_up, but for some reason, my tests don't seem to think this controller has a valid URL for the create action. Why so?



      Additional steps



      Upon following D1ceWard's suggestion, I pluralized "registration" in my routes, and now the error message changed to a AbstractController::ActionNotFound error. I countered that by following the documentation and added the following block to the top of my tests:



      before(:each) do
      @request.env['devise.mapping'] = Devise.mappings[:user]
      end






      ruby-on-rails rspec devise rspec-rails






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 10:15







      Upvote Me

















      asked Nov 21 '18 at 9:18









      Upvote MeUpvote Me

      1,86521239




      1,86521239
























          1 Answer
          1






          active

          oldest

          votes


















          1














          Your error is caused by missing pluralization, devise don't know what registration is, but work with registrations.



          Solution :



          # routes.rb
          devise_for :users, controllers: {
          registrations: 'user/registrations'
          }


          You can use rails routes to check all existings routes.



          Devise doc about custom controllers






          share|improve this answer
























          • Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

            – Upvote Me
            Nov 21 '18 at 10:05






          • 1





            Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

            – Upvote Me
            Nov 21 '18 at 10:11











          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%2f53408725%2factioncontrollerurlgenerationerror-for-devise-registration-controller%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Your error is caused by missing pluralization, devise don't know what registration is, but work with registrations.



          Solution :



          # routes.rb
          devise_for :users, controllers: {
          registrations: 'user/registrations'
          }


          You can use rails routes to check all existings routes.



          Devise doc about custom controllers






          share|improve this answer
























          • Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

            – Upvote Me
            Nov 21 '18 at 10:05






          • 1





            Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

            – Upvote Me
            Nov 21 '18 at 10:11
















          1














          Your error is caused by missing pluralization, devise don't know what registration is, but work with registrations.



          Solution :



          # routes.rb
          devise_for :users, controllers: {
          registrations: 'user/registrations'
          }


          You can use rails routes to check all existings routes.



          Devise doc about custom controllers






          share|improve this answer
























          • Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

            – Upvote Me
            Nov 21 '18 at 10:05






          • 1





            Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

            – Upvote Me
            Nov 21 '18 at 10:11














          1












          1








          1







          Your error is caused by missing pluralization, devise don't know what registration is, but work with registrations.



          Solution :



          # routes.rb
          devise_for :users, controllers: {
          registrations: 'user/registrations'
          }


          You can use rails routes to check all existings routes.



          Devise doc about custom controllers






          share|improve this answer













          Your error is caused by missing pluralization, devise don't know what registration is, but work with registrations.



          Solution :



          # routes.rb
          devise_for :users, controllers: {
          registrations: 'user/registrations'
          }


          You can use rails routes to check all existings routes.



          Devise doc about custom controllers







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 9:47









          D1ceWardD1ceWard

          590312




          590312













          • Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

            – Upvote Me
            Nov 21 '18 at 10:05






          • 1





            Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

            – Upvote Me
            Nov 21 '18 at 10:11



















          • Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

            – Upvote Me
            Nov 21 '18 at 10:05






          • 1





            Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

            – Upvote Me
            Nov 21 '18 at 10:11

















          Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

          – Upvote Me
          Nov 21 '18 at 10:05





          Hrm, it definitely did something. I now get AbstractController::ActionNotFound. Adding details to the question.

          – Upvote Me
          Nov 21 '18 at 10:05




          1




          1





          Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

          – Upvote Me
          Nov 21 '18 at 10:11





          Wait, nevermind, I had to follow more documentation, but that was the solution. Thank you :) I'll complete the answer.

          – Upvote Me
          Nov 21 '18 at 10:11




















          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%2f53408725%2factioncontrollerurlgenerationerror-for-devise-registration-controller%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

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)