title: RoR: update action. rendering path when error
body: <p>Rails project: <code>Project</code> has many <code>Ticket</code>'s.</p>
  
  <p>Path to editing a ticket: <code>/projects/12/tickets/11/edit</code></p>
  
  <p>When updating a Ticket and validation fails, I use <code>render :action =&gt; "edit"</code>.</p>
  
  <p>However, when the edit view renders this time, the path changes to <code>/tickets/11/</code></p>
  
  <p>Which means I lose some parameters. How can I keep the original path?</p>
  
  <p>routes.rb:</p>
  
  <pre><code>  resources :projects do
      resources :tickets
    end
    resources :tickets
  </code></pre>
  
  <p>tickets_controller.rb</p>
  
  <pre><code>  def new
      @ticket = Ticket.new
    end
  
    def create
      @ticket = Ticket.new(params[:ticket])
      @ticket.user_id = session[:user_id]
  
      respond_to do |format|
        if @ticket.save
          format.html { redirect_to project_path(@ticket.project), :notice =&gt; "Ticket was created." }
        else
          format.html { render :action =&gt; "new" }
        end
      end
    end
  
    def edit
      @ticket = Ticket.find(params[:id])
    end
  
    def update
      @ticket = Ticket.find(params[:id])
      respond_to do |format|
        if @ticket.update_attributes(params[:ticket])
          format.html { redirect_to project_ticket_path(@ticket.project, @ticket), :notice =&gt; "Ticket was updated." }
        else
          format.html { render :action =&gt; "edit" }
        end
      end
    end
  </code></pre>