title: Rails validation over redirect
body: <p>I'm trying out the <a href="http://github.com/courtenay/altered_beast" rel="noreferrer">beast</a> forum written in rails and will use this as an example of a problem I keep facing.</p>
  
  <p>The forum has a topics/show action and view with a form at the bottom to create a new post within the topic.</p>
  
  <p>Submitting the form goes to posts/create and if the validation passes redirects back to topics/show and works fine, however if the validation fails (leaving out the body field) you're redirected to the same topics/show and back to the form, with no validation errors... normally if validation fails you're left on whatever/create with render :action => new. </p>
  
  <p>Are the validations being lost in the redirect, and what's the best method of getting it working?</p>
  
  <p>See code below:</p>
  
  <p>PostsController.rb</p>
  
  <pre><code>  def create
      @post = current_user.reply @topic, params[:post][:body]
  
      respond_to do |format|
        if @post.new_record?
          format.html { redirect_to forum_topic_path(@forum, @topic) }
          format.xml  { render :xml  =&gt; @post.errors, :status =&gt; :unprocessable_entity }
        else
          flash[:notice] = 'Post was successfully created.'
          format.html { redirect_to(forum_topic_post_path(@forum, @topic, @post, :anchor =&gt; dom_id(@post))) }
          format.xml  { render :xml  =&gt; @post, :status =&gt; :created, :location =&gt; forum_topic_post_url(@forum, @topic, @post) }
        end
      end
    end
  </code></pre>
  
  <p>TopicsController.rb</p>
  
  <pre><code>  def show
      respond_to do |format|
        format.html do
          if logged_in?
            current_user.seen!
            (session[:topics] ||= {})[@topic.id] = Time.now.utc
          end
          @topic.hit! unless logged_in? &amp;&amp; @topic.user_id == current_user.id
          @posts = @topic.posts.paginate :page =&gt; current_page
          @post  = Post.new
        end
        format.xml  { render :xml  =&gt; @topic }
      end
    end
  </code></pre>
  
  <p>topics/show view</p>
  
  <pre><code>  &lt;% form_for :post, :url =&gt; forum_topic_posts_path(@forum, @topic, :page =&gt; @topic.last_page) do |f| %&gt;
  
    &lt;%= f.error_messages %&gt;
  
    &lt;table width="100%" border="0" cellpadding="0" cellspacing="0"&gt;
      &lt;tr&gt;
        &lt;td rowspan="2" width="70%"&gt;
          &lt;%= f.text_area :body, :rows =&gt; 8 %&gt;
        &lt;/td&gt;
        &lt;td valign="top"&gt;
          &lt;%= render :partial =&gt; "posts/formatting" %&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td valign="bottom" style="padding-bottom:15px;"&gt;
         &lt;%= submit_tag I18n.t('txt.views_topics.save_reply', :default =&gt; 'Save reply') %&gt;
       &lt;/td&gt;
     &lt;/tr&gt;
    &lt;/table&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>Many thanks.</p>