Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

find_scope! error - Could not find a valid mapping ... (Rails and Devise 1.2.1)

Error Message:

Could not find a valid mapping for #<Event id: 10022, event_name: "test", start_date: "2011-03-31", end_date: "2011-03-31", event_description: "test", created_at: "2011-03-30 03:26:01", updated_at: "2011-03-30 03:26:01", is_ecommerce: false, is_secure: false, event_password: nil, notify_rsvp: false, user_id: 20, start_time: "noon", street_address: "", city: "", state: "", country: "", zipcode: "", website_url: nil, status: "Draft", payment_received: false, is_confirmed: false>

Here is the top part of my Full Stack Trace:

devise (1.2.1) lib/devise/mapping.rb:40:in `find_scope!'
devise (1.2.1) lib/devise/controllers/url_helpers.rb:29:in `confirmation_path'
app/controllers/events_controller.rb:163:in `edit'
actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.1) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.1) lib/action_controller/metal/rendering.rb:11:in `process_action'

I've recently Updated: Devise 1.2.1 (I also received the error with 1.2.0) Rails 3.0.5 Ruby 1.8.7 WEBrick 1.3.1

Also, I have this in my routes:

devise_for :users

I used to run fine till the latest updates. Thanks

like image 924
Brad Madigan Avatar asked Mar 31 '11 01:03

Brad Madigan


1 Answers

The problem is that your helper confirmation_path is being overridden by devise's url_helpers.

https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/url_helpers.rb

Basically, devise thinks you want a confirmation path for your event.

Change your route to be something like

match '/admin/events/confirmation/:id' => "events#confirmation", :as => 'confirmation_event'

and then use

redirect_to(confirmation_event_path(@event), :notice => 'Your event has not been confirmed.')

in your controller and anywhere else you were using it.

like image 101
Kyle d'Oliveira Avatar answered Sep 20 '22 18:09

Kyle d'Oliveira