UnknownAttributeError: unknown attribute 'news_id' for Control::Comment
<p>While trying to post comments in the news I am getting the unknown attribute error for the namespace models.</p>

<p>control/news.rb</p>

<pre><code>class Control::News &lt; ApplicationRecord
    belongs_to :user
    belongs_to :control_category, class_name: "Control::Category"
    has_many :control_comments, class_name: "Control::Comment", :foreign_key =&gt; 'control_news_id'
end
</code></pre>

<p>control/comments.rb</p>

<pre><code>class Control::Comment &lt; ApplicationRecord
    belongs_to :control_news, class_name: "Control::News", :foreign_key =&gt; "control_news_id"
end
</code></pre>

<p>Comment Migration File</p>

<pre><code>class CreateControlComments &lt; ActiveRecord::Migration[5.0]
  def up
    create_table :control_comments do |t|
      t.string "name"
      t.string "email"
      t.text "comment"
      t.references :control_news, foreign_key: true
      t.boolean "status", :default =&gt; false
      t.timestamps
    end
    def down
        drop_table :comments
    end
  end
end
</code></pre>

<p>Its not working. Whenever I try to post a comment I am getting the unknown attributes "news_id" but the foreign key is "control_news_id". Please help me to fix it.</p>

<p>Rails console</p>

<pre><code>a = Control::News.find(112)
b = b.control_comments.create(name: "test")

ActiveModel::UnknownAttributeError: unknown attribute 'news_id' for Control::Comment.
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activemodel-5.0.0.1/lib/active_model/attribute_assignment.rb:48:in `_assign_attribute'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activemodel-5.0.0.1/lib/active_model/attribute_assignment.rb:40:in `block in _assign_attributes'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activemodel-5.0.0.1/lib/active_model/attribute_assignment.rb:39:in `each'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activemodel-5.0.0.1/lib/active_model/attribute_assignment.rb:39:in `_assign_attributes'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/attribute_assignment.rb:26:in `_assign_attributes'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activemodel-5.0.0.1/lib/active_model/attribute_assignment.rb:33:in `assign_attributes'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/associations/association.rb:172:in `initialize_attributes'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/associations/association.rb:254:in `block in build_record'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/core.rb:321:in `initialize'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/inheritance.rb:65:in `new'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/inheritance.rb:65:in `new'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/reflection.rb:152:in `build_association'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/associations/association.rb:253:in `build_record'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/associations/collection_association.rb:165:in `build'
    from /Users/santosharyal/.rvm/gems/ruby-2.2.2/gems/activerecord-5.0.0.1/lib/active_record/associations/collection_proxy.rb:294:in `build'
    from (irb):7
</code></pre>