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

  • Home
  • SEARCH
  • 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 8593957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:06:07+00:00 2026-06-12T00:06:07+00:00

I have a Client model that can have many Projects . These are my

  • 0

I have a Client model that can have many Projects.

These are my view files:

edit.html.erb

<%= form_for(@project) do |f| %>
  <%= render 'fields', :f => f %>
  <%= f.submit Create %>
<% end %>

_fields.html.erb

<div>
    <%= f.label :name %><br/>
    <%= f.text_field :name %>
</div>
<div>
    <%= f.label :client_id %><br/>
    <%= f.select(:client_id, current_user.client_names) %>
</div>

This is easy and works great.

But is there a way to create a Project from within a Client view as well?

For example on the client edit page it would be nice to have a link New Project for this Client that leads to the above New Project form, but with the respective client preselected in the select box.

Can this be done somehow?

I can’t seem to find a way to pass the Client ID to the New Project form.

Thanks for any help!

  • 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-12T00:06:08+00:00Added an answer on June 12, 2026 at 12:06 am

    This is certainly possible, but requires passing the client id to the new_projects_path. This can be done by nesting the routes to projects inside of clients, or just appending the client id. The difference would be URLs that look like the following:

    /clients/1/projects/new
    - or -
    /projects/new?client_id=1
    

    In your projects controller, you should be able to instantiate the @project variable with a preselected client:

    @project = Project.new :client_id => params[:client_id]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a client application I have a DBIx::Class model 'Todo' that can be linked
I currently have a client that wants me to 'abstract' out a domain model
I have a model with many fields (nearly 40). The client wants the fields
I have a model Client which has many :tours, association in it. I am
I have an Entity Framework model with one-to-many relationships: Client entity could have many
I have a Client and ProposalRequest model that look like this: class Client <
I know that the asp.net repeater doesnt have a Client side object model, and
I have two models: Client and Invoice. Every client can have many invoices, every
I have a Client model with a OneToOne relationship to User, to extend the
I have HABTM models Client and Book . Client model has a bookshelf_color attribute

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.