The code below displays peferctly what i want to accomplish (show store name and item name).But when i subtitute @onedeal=@deal.find_with_ids(62) with @onedeal=@deal.find(params[:id]) i get an error Couldn't find Deal without an ID.What method should i use to fetch deal ID dynamically?The relationship between the Deal and store model is has many :through.
controller
@deal=@city.deals
@onedeal=@deal.find_with_ids(62)
@store=@onedeal.stores.first(params[:store_id])
view
<% @deal.each do |deal| %>
<%=deal.item_name %>
<%end%>
<%=@store.store_name %>
That error means that
params[:id]is empty. Check yourparamshash to see what it contains, and verify that your action is getting the input it expects.You are absolutely using the
.findmethod as intended, so I don’t think that’s the issue.