views:

45

answers:

2

Im trying to define a new function in my Controller class. I made up everything using Scaffolding and it worked okay. But now, when i add a new function to the controller, setting up the view and so, it says some extrange error (tries to load show action when i asked for login).

Whats scaffold doing that im not? Thanks

A: 

You should add a new entry in your routing file (RAILS_APP/config/routes.rb)

if You have for example an Foo controller, and You will ad a bar functon

map.resources :foos, :collection => {:bar, :get} # /foos/bar
map.resources :foos, :member => {:foo, :get} # /foos/1/bar

If this don't solve Your problem, paste Your routing and controller files.

astropanic
A: 

Scaffolding will add map.resources :controller_name to your config/routes file.

This line will generate 7 restful actions for your controller, so if you specify any new action in your controller, it can't recognize it unless you add the action to your routes.

If you want to see all the route actions for you app you can run this rake command

rake routes it will show all the routes that will be used in your application.

vamsi