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