I am trying to make it so that when you click the corresponding subject you are taken to the correct sub section which is on a different controller. Basically the subject controller/model is something like the Mercedes Benz, I want it so when you click that subject you are taken to a page on ‘car’ controller to view active posts or discussions related to that subject.
subject controller class:
def index
@subject = Subject.all
@car = Car.find(params[:id])
end
end
subject index:
<h2>Choose Your Car Model</h2>
<dl>
<% @subject.each do |subject| %>
<dd>
<a href="<%=car.name %>"><%= subject.name %></a><br />
</dd>
<% end %>
</dl>
error message when viewing subject index:
ActiveRecord::RecordNotFound in SubjectController#index
Couldn't find Car without an ID
Generally the
indexmethod does not receive the:idparameter, but theshowmethod does. If you’re using nested resources, you may be looking for the:car_idparameter instead:Always check your
log/development.logto see what the contents ofparamsis as well as checking that the route is defined properly withrake routes.