title: Error: render action new in create method
body: <p>My application has two associated models: Magazine and Article: 
  </p>
  
  <pre><code>class Magazine &lt; ActiveRecord::Base
    has_one :article
  end
  
  class Article &lt; ActiveRecord::Base
    belongs_to :magazine
    validation_presence_of :title
  end
  </code></pre>
  
  <p>From the Magazine show page I can create a new Article, so my routes.rb is configured like:</p>
  
  <pre><code>resources :magazines, :shallow =&gt; true do
    resources :articles
  end
  </code></pre>
  
  <p>and in the Magazine show page I have the link "New article", like:</p>
  
  <pre><code>&lt;%= link_to 'New article', new_magazine_article_path(@article)
  </code></pre>
  
  <p>and an article helper to pass correct parameters to the form_for:</p>
  
  <pre><code>module ArticlesHelper
    def form_for_params
      if action_name == 'edit'
        [@article]
      elsif action_name == 'new'
        [@magazine, @article]
      end
    end
  end
  </code></pre>
  
  <p>so I can use Article form_for like:</p>
  
  <pre><code>&lt;%= simple_form_for(form_for_params) do |f| %&gt; ...
  </code></pre>
  
  <p>The ArticlesController methods for new and create are:</p>
  
  <pre><code>respond_to :html, :xml, :js
  
  def new
    @magazine = Magazine.find(params[:magazine_id])
    @article = Article.new
  end
  
  def create
    @magazine = Magazine.find(params[:magazine_id])
    @article = @magazine.build_article(params[:article])        
    if @article.save
      respond_with @magazine # redirect to Magazine show page
    else
      flash[:notice] = "Warning! Correct the title field."
      render :action =&gt; :new
    end
  end
  </code></pre>
  
  <p>The problem occurs when there is a validation error with the title attribute, and the action new is rendered. In this moment I get the message: <strong>undefined method `model_name' for NilClass:Class</strong> in the first line of form_for. I think it is because the <strong>@magazine</strong> parameter passed in the helper.</p>
  
  <p>How could I solve this problem withou use redirect_to ? (I want to mantain the other attributes that were filled in the form .)</p>