# Can't load params\[:id\]

**URL:** <https://www.ruby-forum.com/t/cant-load-params-id/139579>\
**Category:** Rails\
**Created:** [June 5, 2008, 4:04am UTC](https://www.ruby-forum.com/t/cant-load-params-id/139579 "2008-06-05T04:04:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbobker](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@tbobker](https://www.ruby-forum.com/u/tbobker)\
**Post date:** [June 5, 2008, 4:04am UTC](https://www.ruby-forum.com/t/cant-load-params-id/139579/1 "2008-06-05T04:04:53Z")

</div>

really tricky problem. narrowed down the issue.

view code:

\<%= button\_to “Empty cart”,  
{:controller =\> ‘registration’,:action =\> :empty\_cart, :id =\>  
@location\_id}, :class =\> ‘button’ %\>

generates html code (so @location\_id is populating):

and thus produces in the action in the registrations controller:

params[:id] = nil

in my block:

```
def empty_cart
    session[:cart] = nil redirect_to_index(nil,params[:id])
end

```

This works intermittently. I have no idea what is going on here.  
below is routes.rb  
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-  
ActionController::Routing::Routes.draw do |map|

# from savage beast

map.from\_plugin :savage\_beast

map.resources :sponsors

map.resources :exertions

map.resources :meetings

map.resources :faqs

map.resources :rights

map.resources :roles

map.resources :orders

map.resources :locations

map.resources :measurements

map.resources :exercises

map.resources :franchises

map.resources :users

map.resources :news\_items

map.resources :meeting\_users do |meeting\_user|  
meeting\_user.resources :exertions  
end

map.resources :boot\_camps do |boot\_camp|  
boot\_camp.resources :time\_slots do |time\_slot|  
time\_slot.resources :meetings  
end  
end

map.manage\_meetings ‘boot\_camps/:boot\_camp\_id/manage\_meetings/:id’,  
:controller =\> “time\_slots”, :action =\> “manage\_meetings”

# 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 =\> “base”, :action =\> “home”

# the bootcamp calendar

map.calendar\_by\_location “/location\_info/calendar/:id/:year/:month”,  
:controller =\> “location\_info”,  
:action =\> “calendar”,  
:requirements =\> {:year =\> /\d{4}/,:month =\> /\d{1,2}/},  
:defaults =\> {:year =\> Date.today.year,:month =\> Date.today.month}

map.browse\_locations “/location\_info/index/:us\_state/:id”,  
:controller =\> “location\_info”,  
:action =\> “index”,  
:requirements =\> {:us\_state =\> /[A-Z]{2}/,:id =\> /[0-9]\*/}

# map.manage\_attendance “/attendance/Locations/:us\_state/:id”,

# :controller =\> “boot\_camp\_info”,

# :action =\> “Locations”,

# :requirements =\> {:us\_state =\> /[A-Z]{2}/,:id =\> /[0-9]\*/}

map.add\_measurements “/admin/record\_exercises/:bootcamp\_id/:user\_id”,  
:controller =\> “admin”,  
:action =\> “record\_exercises”

# Install the default routes as the lowest priority.

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

# custom routes

map.admin\_index “admin/”, :controller =\> ‘admin’, :action =\> :index

end
