Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:51:39+00:00 2026-06-10T10:51:39+00:00

I have a nested route: resources :period_registrations do member do post :save_period end that

  • 0

I have a nested route:

resources :period_registrations do
  member do
    post :save_period
  end

that points to my controller action:

 def save_period
    @period_registration = PeriodRegistration.new(params[:registration])
    @period_registration.save
    redirect_to root_path
  end

and I have a test:

test "should get save_period" do
    sign_in(FactoryGirl.create(:user))
     assert_difference('Event.count') do
      post :save_period, period_registration: FactoryGirl.attributes_for(:period_registration)
    end
    assert_not_nil assigns(:period_registration)

    assert_response :success
  end

That when run generates the following error:

 1) Error:
test_should_get_save_period(PeriodRegistrationsControllerTest):
ActionController::RoutingError: No route matches {:period_registration=>{}, :controller=>"period_registrations", :action=>"save_period"}

What looks odd to me is that :period_registration is empty. Should it be? How can I solve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:51:41+00:00Added an answer on June 10, 2026 at 10:51 am

    post should be defined for collection, i.e. you need to change your routing:

    post :save_period, :on => :collection
    

    instead of member block. As an example, rails build-in create (generated by the resources) method also binded to a collection.

    Additional notes:

    1. You have an error in your controller: PeriodRegistration.new(params[:registration]), but should be PeriodRegistration.new(params[:period_registration]).
    2. And there is a typo in test: should get save_period => should post save_period
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nested route like so: resources :apps do resources :issues end the
I have a resourceful route, with a post route nested within it: resources :groups,
I have a nested route as: resources :wsps do member do get :location get
I have a nested route: resources :stories do resources :comments end this is my
I have a constrained route that matches usernames like this: controller :users, :path =>
Ok guys so I have a nested route like this: resources :apps do resources
I have nested resources as follows: employer.rb class Employer < ActiveRecord::Base has_many :listings end
I have a nested route in rails 3 mapped as resources :maps do resource
I have a nested model form that isn't functioning properly. The POST is to
I have a nested resource, setup like this: resources :chickens do resources :eggs end

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.