title: Displaying errors in Ruby on Rails
body: <p>I have trouble displaying errors in Rails. 
  Here is my controller</p>
  
  <pre><code>def new
      if current_user
          @edible = Edible.new 
      else 
          flash[:notice] = "You need to be signed in for this action"
          redirect_to root_path
      end
  end
  
  def create
      @edible = Edible.new(params[:edible])
      if @edible.valid? &amp;&amp; current_user.edibles.push(@edible)
          if(params[:edible][:pickup] == "1")
              respond_to do |format|
                  format.html { redirect_to new_user_edible_pick_up_adress(current_user.id, @edible.id) }
              end
          else
              respond_to do |format|
                  format.html { redirect_to(user_edible_path(current_user.id, @edible.id), 
                                 :success =&gt; "Product saved")
                               }
              end
          end
  
      else
          respond_to do |format|
              format.html { redirect_to(new_user_edible_path(current_user.id,
                  :alert =&gt; "Error happend" ))
              }
          end
  
      end
  
  end
  </code></pre>
  
  <p>Form:</p>
  
  <pre><code>&lt;%= nested_form_for @edible, :url =&gt; user_edibles_path,
      :html =&gt; { :multipart =&gt; true, :class =&gt; "signin" } do |f| %&gt;
      &lt;%= render 'shared/alerts', :object =&gt; @edible   %&gt;
  #standart code further...
  </code></pre>
  
  <p>And partial:</p>
  
  <pre><code> &lt;% if flash[:notice] %&gt;
        &lt;p class="notice"&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;
      &lt;% end %&gt;
  &lt;% if flash[:error] %&gt;
      &lt;p class="error"&gt;
          &lt;% if object %&gt;
              &lt;%= flash[:error] %&gt;
              &lt;ul&gt;
              &lt;% object.errors.full_messages.each do |msg| %&gt;
                  &lt;li&gt; &lt;%= msg %&gt; &lt;/li&gt;
              &lt;% end %&gt;
              &lt;/ul&gt;
          &lt;% end %&gt;
      &lt;/p&gt;
  &lt;% end %&gt;
  &lt;% if flash[:alert] %&gt;
      &lt;p class="alert"&gt;&lt;%= flash[:alert] %&gt;&lt;/p&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I assume that @edible variable is not passed when redirecting to new page, so Rails run object.errors on new instance every time.
  Am I missing some obvious thing?</p>