Hi there I wrote a small rails app for my university dept about a year
or
so ago to deal with mailing list generation and display of staff details
and all was working fine up until last week when we did a version
update.
Im not someone who uses rails regularly and so Im a bit at a loss.
The normal functionality search and display of the rails program is
fine,
it searches and diplays user deatails without issues, but however when I
try to “logon” to a session as the administrator to add a new user I get
the following error:
ActiveRecord::RecordNotFound in UsersController#show
Couldn’t find User with ID=login
RAILS_ROOT: /export/webserver/raid/htdocs/users
Application Trace http://www.met.reading.ac.uk/users/login# |
Framework
Trace http://www.met.reading.ac.uk/users/login# | Full
Tracehttp://www.met.reading.ac.uk/users/login#
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:1620:in
find_one' /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:1603:in
find_from_ids’
/usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.14/lib/active_record/base.rb:620:in
find' /export/cree/raid/htdocs/users/app/controllers/users_controller.rb:33:in
show’
Request
Parameters:
{“id”=>“login”}
Show session dump http://www.met.reading.ac.uk/users/login#
Response
Headers:
{“Content-Type”=>“”,
“Cache-Control”=>“no-cache”}
So this appears to be an issue with routes.rb or some other issue of
routing? I have not changed any of the routing configuration files at
all
and the format appears to comply with the current standards.
It looks tome like the directives
map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘sessions’, :action => ‘destroy’
Are not working? And rails is trying to interpret “login” as if it were
just another database row
Here is the routes.rb file
ActionController::Routing::Routes.draw do |map|
map.resources :users, :sessions
The priority is based upon order of creation: first created →
highest
priority.
Sample of regular route:
map.connect ‘products/:id’, :controller => ‘catalog’, :action =>
‘view’
Keep in mind you can assign values other than :controller and
:action
Sample of named route:
map.purchase ‘products/:id/purchase’, :controller => ‘catalog’,
:action => ‘purchase’
This route can be invoked with purchase_url(:id => product.id)
Sample resource route (maps HTTP verbs to controller actions
automatically):
map.resources :products
Sample resource route with options:
map.resources :products, :member => { :short => :get, :toggle =>
:post }, :collection => { :sold => :get }
Sample resource route with sub-resources:
map.resources :products, :has_many => [ :comments, :sales ],
:has_one
=> :seller
Sample resource route within a namespace:
map.namespace :admin do |admin|
# Directs /admin/products/* to Admin::ProductsController
(app/controllers/admin/products_controller.rb)
admin.resources :products
end
You can have the root of your site routed with map.root – just
remember to delete public/index.html.
map.root :controller => “users”
See how all your routes lay out with “rake routes”
Install the default routes as the lowest priority.
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘sessions’, :action => ‘destroy’
end
Previous Versions:
Rails version 2.2.3
Ruby version 1.8.6
New Versions:
Rails version 2.3.14
Ruby version 1.8.7
As Is ai Im not a day to day RoR programmer so any help or advice would
be
gratefully accepted.