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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:18:19+00:00 2026-05-20T17:18:19+00:00

Rails newbie here and I’m stumped. In Rails I have a Project Model which

  • 0

Rails newbie here and I’m stumped. In Rails I have a Project Model which has_many Tasks. Lets say I have a view that is displaying 5 projects and each project has a ‘New Task’ link so that the user can add a new task to any one of the projects. So:

Project 1
New Task

Project 2
New Task
etc.

If the New Task link looks like

link_to ‘New Task’, new_task_path

what is the best way to tell the ‘new’ action on the tasks controller which link was clicked? I figure I have to pass the project_id to the new task, but I can’t solve out how to do it.

Help appreciated as always!

  • 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-05-20T17:18:20+00:00Added an answer on May 20, 2026 at 5:18 pm

    Depends how your routes are defined, but if tasks are defined as a subresource of a project (such as the following) then it’s pretty simple.

    resources :projects do
      resources :tasks
    end
    

    This will generate routes such as:

    new_project_task GET    /projects/:project_id/tasks/new(.:format)                         {:controller=>"tasks", :action=>"new"}
    

    And then you can link to it via:

    link_to 'New Task', new_project_task_path(@project)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Rails newbie here. I have a list of items which can have a status
Rails newbie here. If I have a model and a table associated with it,
Rails newbie here. I have a legacy sqlite3 database that I have no control
Rails newbie here struggling with a small project. I am creating a simple ship
I am a newbie to Rails and I have seen that to write HTML
A rails newbie here I have 2 actions in my controller 1) index 2)
please help a newbie in Rails :) I have protect_from_forgery call (which is given
Hi (huge Rails newbie here), I have the following models: class Shop < ActiveRecord::Base
Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
Rails 3 newbie here... I'm working to create a devise auth system that like

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.