title: association between two model in rails , controller
body: <p>I can not find the issue with my association, but continuously getting error related to the association. I added has_many to Schools and belongs_to to members.</p>
  
  <pre><code> class CreateMembers &lt; ActiveRecord::Migration[5.0]
    def change
     create_table :members do |t|
      t.string :name
      t.string :email
      t.timestamps
    end
  end
  </code></pre>
  
  <p>end</p>
  
  <pre><code> class CreateSchools &lt; ActiveRecord::Migration[5.0]
  def change
  create_table :schools do |t|
    t.string :name
  
    t.timestamps
  end
  </code></pre>
  
  <p>end
    end</p>
  
  <pre><code> class AddSchoolRefToMembers &lt; ActiveRecord::Migration[5.0]
  def change
    add_reference :members, :school, foreign_key: true
  end
  </code></pre>
  
  <p>end</p>
  
  <p>Controller:</p>
  
  <pre><code>class MembersController &lt; ActionController::Base
   before_action :set_school
  def index
   @members = Member.all
  end
  def new
    @member = Member.new
  end
  
  def create
   @member = Member.new(member_params)
   @member.school = @school
   @member.save
   redirect_to members_path
  end
  
  
  private
  
  def set_school
   @school = School.find(params[:school])
  
  end
  
  def member_params
    params.require(:member).permit(:name, :email,:school)
  end
  </code></pre>
  
  <p>end</p>