Ok so I am making a directory, the flow of the directory should be
category to state to county to city to zip. I cant get it to work so
that when you click on a certain category it links to you all the
states it has. so far this is what i have.
routes.rb
map.resources :categories, :has_many => :states
map.resources :states, :has_many => :counties
…
So they start off in the show action of the categories controller
which is
categories_controller.rb
def show
@categories = Category.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
end
end
here is my show view for categories
show.html.erb
Listing categories
<%= link_to category.title, state_path(@state) %> |
here is my states controller
states_controller.rb
def index
@states = @category.states
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @states }
end
end
and here is my index view for states
index.html.erb
Listing States
<%= link_to state.title, county_path(@county)%> |
now I can get to the categories view and see all the categories but
when I click on a specific category to go to show all the states it
has it throws a error. Any help would be greatly appreciated, thnks
in advance.