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 8111431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:06:56+00:00 2026-06-06T02:06:56+00:00

I am trying to create nested routes for a project that has many boards.

  • 0

I am trying to create nested routes for a project that has many boards.

First I am creating a link to a new board:

<%= link_to 'New Board', new_project_board_path(@project) %>

In routes.rb I just nested the restful routes:

resources :projects do
  resources :boards
end

And in the boards controller I adapted the new and create action as follows:

    def new
        @project = Project.find(params[:project_id])
        @board = @project.boards.new

        respond_to do |format|
          format.html # new.html.erb
          format.json { render json: @board }
        end
  end



 def create
    @project = Project.find(params[:project_id])
    @board = @project.boards.new(params[:board])

    respond_to do |format|
      if @board.save
        format.html { redirect_to @board, notice: 'Board was successfully created.' }
        format.json { render json: @board, status: :created, location: @board }
      else
        format.html { render action: "new" }
        format.json { render json: @board.errors, status: :unprocessable_entity }
      end
    end
  end

At least I also changed the _form.html.erb into:

<%= form_for([@project, @board]) do |f| %>

etc.

My problem starts when I click the button create board (so the new action is executed) it says no route matches. I guess it has to do with the create action because it doesn’t get the id of the project anymore? I really don’t know what else to change and where.

  • 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-06T02:06:58+00:00Added an answer on June 6, 2026 at 2:06 am

    Seems your error is here

    format.html { redirect_to @board, notice: 'Board was successfully created.' }
    

    You don’t have non-nested :boards resources, do you? Try to change this line to

    format.html { redirect_to [@project, @board], notice: 'Board was successfully created.' }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create nested array's dynamically from a string that has been
I am trying to create a nested JSON that has data from various db
I'm trying to create a perma link for a nested attribute. For example, look
I'm using the awesome_nested_set plugin in my Rails project. I'm trying to create nested
I'm trying to create a chess game board with 8x8 buttons. I'm using nested
Trying to create a nested hash in Perl that is populated with entries from
I'm trying to create a nested storyboard structure to help break up a huge
I am trying to create nested resources where the sub-resource doesn't have an existence
Background / Goal More or less, I'm trying to create a nested group of
I am trying to create a TreeView nested structure with the use of self

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.