Restful routing help

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.


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


def show
@categories = Category.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }

here is my show view for categories


Listing categories

<% for category in @categories %> <% end %>
<%= link_to category.title, state_path(@state) %>

here is my states controller


def index
@states = @category.states
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @states }

and here is my index view for states


Listing States

<% for states in @categories.states %> <% end %>
<%= 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.

Does anyone know? or can point me in the right direction?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs