undefined method `devise_for' for main:Object

376 views
Skip to first unread message

Paulo Cesar

unread,
Jun 9, 2010, 10:51:44 AM6/9/10
to Devise
Hi everybody, I'm having a problem with devise here. Actually I must
be doing something very lame, because this was supposed to work.

Ok, I have a model User, and configured it to:

devise :database_authenticatable, :confirmable, :recoverable, :rememberable, :trackable, :validatable

Then I created the table with the following migration:

create_table :users do |t|
t.string :domain
t.string :name
t.string :permalink
t.database_authenticatable
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.timestamps
t.timestamps
t.string :logo_file_name
t.string :logo_content_type
t.integer :logo_file_size
t.datetime :logo_updated_at
t.text :about
end

And added to routes.rb the following line:

devise_for :users

And then configured environment with:

config.gem "devise"

But when I run:

User.create(:name => "puelocesar", :email =>
"puelo...@gmail.com", :password => "hild23")

I get the following error:

RuntimeError: Could not find a valid mapping for #<User:0x103580b70>
from /Library/Ruby/Gems/1.8/gems/devise-1.0.7/lib/devise/mapping.rb:
49:in `find_scope!'
from /Library/Ruby/Gems/1.8/gems/devise-1.0.7/app/models/
devise_mailer.rb:23:in `setup_mail'
from /Library/Ruby/Gems/1.8/gems/devise-1.0.7/app/models/
devise_mailer.rb:7:in `confirmation_instructions'
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
base.rb:459:in `__send__'
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
base.rb:459:in `create!'
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
base.rb:452:in `initialize'
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
base.rb:395:in `new'
from /Library/Ruby/Gems/1.8/gems/actionmailer-2.3.5/lib/action_mailer/
base.rb:395:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/devise-1.0.7/lib/devise/models/
confirmable.rb:60:in `send_confirmation_instructions'

And when I run rake routes, I get the following error:

rake aborted!
undefined method `devise_for' for main:Object

Can anyone help me on this one?

Paulo Cesar

unread,
Jun 9, 2010, 11:09:04 AM6/9/10
to Devise
Opa, o problema do user.create eu já achei... É porque eu estava
usando :confirmable, mas ainda não tenho nada de envio de emails
configurado por enquanto.. Desabilitei e funcionou de boa. Agora por
que está dando esse erro no routes?
> "pueloce...@gmail.com", :password => "hild23")

José Valim

unread,
Jun 9, 2010, 11:09:00 AM6/9/10
to plataforma...@googlegroups.com
I guess you need to do map.devise_for instead of devise_for in your config/routes.rb
--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/

Paulo Cesar

unread,
Jun 9, 2010, 12:07:15 PM6/9/10
to Devise
Yes, that's it. Thanks José
> > "pueloce...@gmail.com", :password => "hild23")

Alf Mikula

unread,
Jun 12, 2010, 9:52:02 AM6/12/10
to Devise
It would be nice to have this reflected in the README...I just hit the
same problem. Are we seeing a difference between Rails 2.x and Rails
3.0 here?

-Alf
> > "pueloce...@gmail.com", :password => "hild23")

José Valim

unread,
Jun 12, 2010, 9:56:39 AM6/12/10
to plataforma...@googlegroups.com
Done, README updated. And yes, there is a lot of difference between 2.3 and 3.0.

Alf Mikula

unread,
Jun 12, 2010, 10:37:27 AM6/12/10
to plataforma...@googlegroups.com
Yeah, I was aware that routes have changed in Rails 3.0, but I haven't
had a chance to work with it just yet.

Thanks for the quick response!

-Alf

Reply all
Reply to author
Forward
0 new messages