title: ForbiddenAttributesError for polymorphic model in Rails 4
body: <p>Rails 4 ships with strong_parameters, which is a great addition - but I've run into a problem with it. I have a polymorphic model <code>Comment</code> and I cannot for the life of me get the controller to accept the parameters it needs. Here is my code (shortened for clarity): </p>
  
  
  
  <p>Routes: </p>
  
  <pre class="lang-rb prettyprint-override"><code>resources :articles do
    resources :comments
  end
  </code></pre>
  
  <p>Models: </p>
  
  <pre class="lang-rb prettyprint-override"><code>class Article &lt; ActiveRecord::Base
    has_many :comments, :as =&gt; :commentable
  end
  
  class Comment &lt; ActiveRecord::Base
    belongs_to :commentable, :polymorphic =&gt; true
  end
  </code></pre>
  
  <p>Controller: </p>
  
  <pre class="lang-rb prettyprint-override"><code>class CommentsController &lt; ApplicationController
    before_action :get_commentable
  
    def create
      @comment = @commentable.comments.new(comment_params)
      if @comment.save
        redirect_to @commentable, :notice =&gt; "Thank you!"
      else
        render :new
      end
    end
  
  private
  
    def get_commentable
      resource, id = request.path.split("/")[1,2]
      @commentable = resource.singularize.classify.constantize.find(id)
      redirect_to :home unless defined?(@commentable)
    end
  
    def comment_params
      params.require(:comment).permit(:title, :message)
    end
  end
  </code></pre>
  
  <p>Posted params (from form on articles#show): </p>
  
  <pre class="lang-rb prettyprint-override"><code>{"authenticity_token"=&gt;"v70nN8aFpofNw9vbVjhpsm9SwLOwKlOpNOEOTozUwCk=",
  "comment"=&gt;{"title"=&gt;"Test","message"=&gt;"Testing"},
  "article_id"=&gt;"1"}
  </code></pre>
  
  <p>Looks to me like it should work, yet whatever I try I get <code>ActiveModel::ForbiddenAttributesError in CommentsController#create</code> - even when I try </p>
  
  <pre class="lang-rb prettyprint-override"><code>  def comment_params
      params.permit! 
    end
  </code></pre>
  
  <p>in the controller. I have no such problems with my other (non-polymorphic) models, which is why I suspect it has something to do with the polymorphism. Any ideas? </p>