Newbie question: Routing Issues since rails version update?

28 views
Skip to first unread message

DDale

unread,
Sep 20, 2012, 6:13:54 AM9/20/12
to rubyonra...@googlegroups.com
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 | Framework Trace | Full Trace
/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

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.

Franz Strebel

unread,
Sep 20, 2012, 6:16:25 AM9/20/12
to rubyonra...@googlegroups.com
Can you show us the code from the method show from this controller?

/export/cree/raid/htdocs/users/app/controllers/users_controller.rb:33:in `show'


DDale

unread,
Sep 20, 2012, 6:24:17 AM9/20/12
to rubyonra...@googlegroups.com
Here it is... the normal display index and "show" functionality still works fine.

# GET /users/1
  # GET /users/1.xml
  def show

    require 'curb'

    @user = User.find(params[:id])

    if File.exist? "/home/#{@user.Personal_Web}/public_html/userdetails.html"
 #     #{@user.Personal_Web}/public_html/userdetails.html
      userurl = Curl::Easy.perform(constructedurl)
      @userwebdetails = userurl.body_str
    else 
        
      @userwebdetails = "No User Details Found"
    
    end
    
        
    if !@user.CentaurUID.blank?
    @CentaurUIDValue = @user.CentaurUID
    @CentaurUIDValue = @CentaurUIDValue.gsub(".", "=2E")
    @CentaurUIDValue = @CentaurUIDValue.gsub("@", "=40")
    @CentaurURL = Curl::Easy.perform(@CentaurURLValue)
    @CentaurDetails = @CentaurURL.body_str
    end
      
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @user }
    end
  end

Frederick Cheung

unread,
Sep 20, 2012, 9:33:57 AM9/20/12
to rubyonra...@googlegroups.com


On Thursday, September 20, 2012 11:13:54 AM UTC+1, DDale wrote:

  # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
  map.root :controller => "users"

I wonder if doing map.root and specifying only a controller (but not an action) does weird stuff. I'd try either changing this to add the appropriate action or move your login/logout routes higher up

Fred

DDale

unread,
Sep 20, 2012, 11:23:17 AM9/20/12
to rubyonra...@googlegroups.com
In the logs I am seeing this, could this be the key? (pardon the pun)

"DEPRECATION WARNING: Giving :session_key to SessionStore is deprecated, please use :key instead. (called from new at /usr/lib64/ruby/gem/1.8/gems/actionpack-2.3.14/lib/action_controlle/middleware_stack.rb:72) "
Reply all
Reply to author
Forward
0 new messages