I think the issue is that you have a general route to the checkout
controller and then you have a map.checkout route that is after the
map.resources :checkout route. so when you use checkout_path you will
get the edit task and not the checkout "route" that you have setup...

Try changing map.checkout to map.checkout-something-else and see if
that fixes the issue...



On Jun 17, 2:42 pm, Tyler Knappe <[email protected]>
wrote:
> I have a problem with my routing.  When a user performs an illegal
> checkout action (end time < start time) it should route back to to the
> 'checkout' action.  However, it is instead going to the 'edit' action.
>
> <b>'rake routes' </b>
>
>  users GET    /users(.:format)                   {:controller=>"users",
> :action=>"index"}
>                   POST   /users(.:format)
> {:controller=>"users", :action=>"create"}
>          new_user GET    /users/new(.:format)
> {:controller=>"users", :action=>"new"}
>         edit_user GET    /users/:id/edit(.:format)
> {:controller=>"users", :action=>"edit"}
>              user GET    /users/:id(.:format)
> {:controller=>"users", :action=>"show"}
>                   PUT    /users/:id(.:format)
> {:controller=>"users", :action=>"update"}
>                   DELETE /users/:id(.:format)
> {:controller=>"users", :action=>"destroy"}
>       new_session GET    /session/new(.:format)
> {:controller=>"sessions", :action=>"new"}
>      edit_session GET    /session/edit(.:format)
> {:controller=>"sessions", :action=>"edit"}
>           session GET    /session(.:format)
> {:controller=>"sessions", :action=>"show"}
>                   PUT    /session(.:format)
> {:controller=>"sessions", :action=>"update"}
>                   DELETE /session(.:format)
> {:controller=>"sessions", :action=>"destroy"}
>                   POST   /session(.:format)
> {:controller=>"sessions", :action=>"create"}
>              labs GET    /labs(.:format)
> {:controller=>"labs", :action=>"index"}
>                   POST   /labs(.:format)
> {:controller=>"labs", :action=>"create"}
>           new_lab GET    /labs/new(.:format)
> {:controller=>"labs", :action=>"new"}
>          edit_lab GET    /labs/:id/edit(.:format)
> {:controller=>"labs", :action=>"edit"}
>               lab GET    /labs/:id(.:format)
> {:controller=>"labs", :action=>"show"}
>                   PUT    /labs/:id(.:format)
> {:controller=>"labs", :action=>"update"}
>                   DELETE /labs/:id(.:format)
> {:controller=>"labs", :action=>"destroy"}
>    lab_categories GET    /lab_categories(.:format)
> {:controller=>"lab_categories", :action=>"index"}
>                   POST   /lab_categories(.:format)
> {:controller=>"lab_categories", :action=>"create"}
>  new_lab_category GET    /lab_categories/new(.:format)
> {:controller=>"lab_categories", :action=>"new"}
> edit_lab_category GET    /lab_categories/:id/edit(.:format)
> {:controller=>"lab_categories", :action=>"edit"}
>      lab_category GET    /lab_categories/:id(.:format)
> {:controller=>"lab_categories", :action=>"show"}
>                   PUT    /lab_categories/:id(.:format)
> {:controller=>"lab_categories", :action=>"update"}
>                   DELETE /lab_categories/:id(.:format)
> {:controller=>"lab_categories", :action=>"destroy"}
>    checkout_index GET    /checkout(.:format)
> {:controller=>"checkout", :action=>"index"}
>                   POST   /checkout(.:format)
> {:controller=>"checkout", :action=>"create"}
>      new_checkout GET    /checkout/new(.:format)
> {:controller=>"checkout", :action=>"new"}
>     edit_checkout GET    /checkout/:id/edit(.:format)
> {:controller=>"checkout", :action=>"edit"}
>                   GET    /checkout/:id(.:format)
> {:controller=>"checkout", :action=>"show"}
>                   PUT    /checkout/:id(.:format)
> {:controller=>"checkout", :action=>"update"}
>                   DELETE /checkout/:id(.:format)
> {:controller=>"checkout", :action=>"destroy"}
>             login        /
> {:controller=>"sessions", :action=>"new"}
>            signup        /signup
> {:controller=>"users", :action=>"new"}
>         myaccount        /myaccount
> {:controller=>"myaccount", :action=>"myaccount"}
>            logout        /logout
> {:controller=>"sessions", :action=>"destroy"}
>                          /labs/checkout/:id
> {:controller=>"checkout", :action=>"checkout"}
>                          /labs/checkout/:id/update
> {:controller=>"checkout", :action=>"update"}
>          checkout        /labs/checkout/:id/edit
> {:controller=>"checkout", :action=>"update"}
>              root        /
> {:controller=>"home", :action=>"index"}
>                          /:controller/:action/:id
>                          /:controller/:action/:id(.:format)
>
> routes.rb:
>  map.checkout '/labs/checkout/:id', :controller => 'checkout', :action
> => 'checkout'
>   map.checkout '/labs/checkout/:id/update', :controller => 'checkout',
> :action => 'update'
>   map.checkout '/labs/checkout/:id/edit', :controller => 'checkout',
> :action => 'update'
>   map.root :controller => "home"
>
> # default routes
>   map.connect ':controller/:action/:id'
>   map.connect ':controller/:action/:id.:format'
>
> <b>CheckoutController update action: </b>
>
>  def update
>                 @lab = Lab.find(params[:id])
>
>                 respond_to do |format|
>                         if @lab.update_attributes(params[:lab])
>                                 flash[:notice] = 'Lab was successfully
> updated.'
>                                 format.html { redirect_to(@lab) }
>                                 format.xml  { head :ok }
>                         else
>                                 format.html { render :action =>
> "checkout" }
>                                 format.xml  { render :xml =>
> @lab.errors, :status => :unprocessable_entity }
>                         end
>                 end
>       end
>
> <b>LabController update </b>
>
> def update
>     @lab = Lab.find(params[:id])
>
>     respond_to do |format|
>       if @lab.update_attributes(params[:lab])
>         flash[:notice] = 'Lab was successfully updated.'
>         format.html { redirect_to(@lab) }
>         format.xml  { head :ok }
>       else
>         format.html { render :action => "edit" }
>         #format.html { redirect_to :back }
>         format.xml  { render :xml => @lab.errors, :status =>
> :unprocessable_entity }
>       end
>     end
>   end
>
> Let me know if there is something I forgot to include.
>
> Thanks
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to