title: Object's errors and redirect
body: <p>I know, if i will write "redirect_to" instead of "render :action", i'll lose my @object's errors. </p>
  
  <p>My code:</p>
  
  <pre><code>  def play
      @room = params[:id][0,1]
      @current_players = CurrentPlayer.all(:conditions =&gt; {:room =&gt; @room})
    end
  
    def join
      @new_player = CurrentPlayer.new(:user_id =&gt; current_user.id, :team_id =&gt; nil, :room =&gt; params[:room], :mode =&gt; params[:mode], :ip =&gt; request.remote_ip)
      if @new_player.save
        @game = create_game(params[:room], params[:mode])
        if @game
          flash[:notice] = 'Game created'
          return (redirect_to :action =&gt; "game_details", :recent =&gt; true)
        else
          flash[:error] = 'Game not created'
        end
     else
       return render(:action =&gt; 'play')
     end
      redirect_to_back
    end 
  </code></pre>
  
  <p>If a user will click a "join" link in play.html.erb, Rails will send request to "join" action, then, if there were errors, i need to show them to user.</p>
  
  <p>But i can't write just redirect_to, and my code is now:</p>
  
  <pre><code>  def join
      @new_player = CurrentPlayer.new(:user_id =&gt; current_user.id, :team_id =&gt; nil, :room =&gt; params[:room], :mode =&gt; params[:mode], :ip =&gt; request.remote_ip)
      if @new_player.save
        @game = create_game(params[:room], params[:mode])
        if @game
          flash[:notice] = 'Game created'
          return (redirect_to :action =&gt; "game_details", :recent =&gt; true)
        else
          flash[:error] = 'Game not created'
        end
     else
      # == Very ugly and not DRY (just copypaste from 'play' action) ==
      @room = params[:id][0,1]
      @current_players = CurrentPlayer.all(:conditions =&gt; {:room =&gt; @room})
      # ===
       return render(:action =&gt; 'play')
     end
      redirect_to_back
    end 
  </code></pre>
  
  <p>How can i avoid that code?</p>