Routes Question

Hi,

At the moment i have a controller called main_controller and in the
views folder a folder called main with all the view files. I have put
in the routes.rb file the following code

map.connect ‘:action/:id’, :controller => ‘main’, :action => ‘home’

The above works fine so for when i enter http://localhost:3006/news i
get the news page and so on.

Inside the main folder in views i have created another folder called
reviews(views/main/reviews/) and placed some view file associated with
reviews. I have also created a new controller called reviews and placed
it in controllers/main/ so now if i click the follwoing link below i get
a routing error No action responed to Main

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘main/tech_reviews’ %>

I can get this to work if i take out the reviews folder from
views/main/reviews and place it just in the views folder but it really
belongs in the main folder as it is part of the main functionality of
the site.

Can someone plase help me organise my routes file to dela with this as
ive tried numerous routes but if i can get the reviews working then the
main doesnt and vice versa.

Stuuf ive tried is:
map.connect ‘:action/:id’, :controller => ‘main/reviews’, :action =>
‘index’

map.connect ‘:action/:id’, :controller => ‘main’, :action => ‘home’

John B. wrote:

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘main/tech_reviews’ %>

Sorry the line above should read

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘main/reviews’ %>

Any help appreciated.

John B. wrote:

John B. wrote:

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘main/tech_reviews’ %>

Sorry the line above should read

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘main/reviews’ %>

Any help appreciated.

Manged to solve it:

Routes.rb
map.connect ‘reviews/:action/:id’, :controller => ‘main/reviews’,
:action => ‘index’

map.connect ‘:action/:id’, :controller => ‘main’, :action => ‘home’

and for the links within my site

<%= link_to ‘Home’, :action => ‘home’, :controller => ‘/main’%>

<%= link_to ‘Reviews’, :action => ‘index’, :controller =>
‘/main/reviews’ %>

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