How do i access ids from a nested resource ?There is no id people_id in@peoples=@city.peoples.i get an error Couldn't find People without an ID.Thank you in advance.
Models
class City < ActiveRecord::Base
has_many :peoples
end
class People < ActiveRecord::Base
belongs_to :city
end
controller
def show
@city = City.find(session[:city_id])
@peoples=@city.peoples
@people=@peoples.find(params[:id])
end
Routes
resources :city, :people
resources :cities do
resources :peoples
end
Your error message refers to model
Deal, but your example refers toCityand childrenPeople. Anyhow, eachPeopleinstance in@Peoples(or@city.peoples) should have its ID attribute available asid— notpeople_id.