Question : In Ruby on Rails, how do I create links to other views that will display the correct results from a related table

My Rails project currently has 6 models:
city_link - belongs_to :cities
city  - belongs_to :states, has_many :city_links
county_link  - belongs_to :counties
county  - belongs_to :states, has_many :county_links
state_link  - belongs_to: states
state  - has_many :counties, has_many :cities, has_many :state_links

There are tables in the database corresponding to each of these models.  There are lots of many-to-one relationships, and I have the proper foreign key columns, e.g. state_id in the state_links, counties, and cities tables.

I have also created scaffolds corresponding to each of the models.

One of the things I want is to have a view where the states are listed, and the user can click a hyperlink called "Show Links", and it will display all of the links associated with that state.  I assumed I could modify the list view for state and use link_to, but I can't seem to figure out what information to feed it.  I tried putting in something like: <%= link_to 'Show Links', :action => '../state_links/list', :id => state %> but that did not work.  I get "no route found to match '/states/../state_links/list/6' with {:method=>:get}".  Maybe this is the wrong way altogether, but I can't find any info on how to do something like this, which seems like a pretty important task to be able to do (show a new page with info from a related table).

I just started using Rails recently, and I am not a professional programmer, so please be easy on me and provide a thorough explanation that a non-professional like myself can understand.

Thanks!

Answer : In Ruby on Rails, how do I create links to other views that will display the correct results from a related table

You are Not linking to another View, but to another Controller..
So you could also try
<%= link_to 'Show Links', :controller=>:state_links, :action => :list, :id => state %>
Random Solutions  
 
programming4us programming4us