title: Keep params after render Ruby on Rails
body: <p>I have a Project that belongs to User. In my user view I have a link to add a new project, with the parameter for the user I want to add the project to.</p>
  
  <pre><code>&lt;%= link_to 'Add new project', :controller =&gt; "project", :action =&gt; "new", :id =&gt; @user %&gt;
  
  Url: /projects/new?id=62 
  </code></pre>
  
  <p>Adding a project to a user works. The problem is when the validation fails while adding a new project and I do a render. </p>
  
  <pre><code>def create
  
      @project = Project.new(params[:project])
  
      if @project.save
          redirect_to :action =&gt; "show", :id =&gt; @project.id
      else
          render :action =&gt; "new"
      end
  
  end
  </code></pre>
  
  <p>view:</p>
  
  <pre><code>&lt;%= form_for @project do |f| %&gt;
  
      &lt;%= f.label :name %&gt;
      &lt;%= f.text_field :name %&gt;
  
      &lt;%= f.hidden_field :user_id , :value =&gt; params[:id] %&gt;
  
      &lt;%= f.submit "Create project" %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>routes</p>
  
  <pre><code>resources :users do
   resources :projects
  end
  </code></pre>
  
  <p>How can I keep the parameter for the user after the render? Or is there some better way to do this? Been looking at a lot of similar questions but can't get it to work.</p>