ruby on rails - NoMethodError: undefined method `each' for # -
ruby on rails - NoMethodError: undefined method `each' for #<State:0x438a110> - 1. country=country.create(:name=>'australia') 2. country.states #<activerecord::associations::collectionproxy []> 3. first_state=state.new(:name=>'queensland') => #<state id: nil, country_id: nil, name: "queensland", created_at: nil, update d_at: nil> 4. first_state.country => nil 5.country.states=first_state **nomethoderror: undefined method `each' #<state:0x438a110>** in model: class state < activerecord::base belongs_to :country class country < activerecord::base has_many :states i new in rails. trying set country_id it's state, give me error. have done right think, still error occurs. please help me out. it's states (plural); it's expecting array country.states = [first_state] ruby-on-rails ruby-on-rails-4