Rails 3, Devise 1.1.2 and routes issue - just can't seem to figure out how to pull gem with working fix

68 views
Skip to first unread message

Alan McCann

unread,
Aug 30, 2010, 1:32:19 PM8/30/10
to Devise
Hi:

I have not been able to figure out how to properly call the gem after
the update to final Rails3 to remove the issue of the bad routes (e.g.
new_user_session shows up in rake routes as user_session_new)

I had been running devise master (because of the oauth2 work) until
this morning.

I have tried various flavors of gem commands to get the gem working
properly.

My latest is

gem "devise", :git => "git://github.com/plataformatec/devise.git",
'branch' => 'v1.1'

This results in the following bundle output
Using devise (1.1.2) from git://github.com/plataformatec/devise.git
(at v1.1)

The gem in my directory show as devise-1.1.2 (I'm using rvm)

However, I still get the issue.

I delete my gemlock file every time I have tried different gemfile
statements to no avail.

Any recommendations about what I could be doing wrong?

Aside: Will master be updated with this routes fix as well?

Thanks

Carlos Antonio da Silva

unread,
Aug 30, 2010, 1:53:59 PM8/30/10
to plataforma...@googlegroups.com
The route change was applied in both v1.1 and master branch. Also, devise 1.1.2, which is the current release, has this change.

People were relating this as an issue in Github, but most of it was related to not updating Devise to latest version, or having to remove the Gemfile.lock and installing gems again.

--
At.
Carlos A. da Silva

Alan McCann

unread,
Aug 30, 2010, 2:16:33 PM8/30/10
to Devise
Thanks for the quick response.

Perhaps I am misunderstanding. I had seen that issue and had tried to
reinstall everything properly.

If the gem is installed correctly, which should I be using going
forward...

"new_user_session_path" or "user_session_new_path"

If it is user_session_new_path, then everything I have is working as
expected. However, if it is supposed to be new_user_session_path, then
somehow my removal and reinstall of the gem isn't working properly and
there is something else I am doing wrong.

Thanks


Carlos Antonio da Silva

unread,
Aug 30, 2010, 2:28:07 PM8/30/10
to plataforma...@googlegroups.com
The right named route is the first one, "new_user_session_path".
It's the same way it was in Rails 2.x, it didn't change.

I believe you could try creating a new gemset (as you're using rvm) and setup everything from scratch, installing Rails 3 and Devise 1.1.2 to see if it's everything fine.

Alan McCann

unread,
Aug 30, 2010, 2:58:36 PM8/30/10
to Devise
OK - got it.

It seems to be this code is not responding as before... I think I had
found this earlier in this group's messages...

devise_for :user, :path => 'account', :skip =>
[:sessions, :registration] do
scope :controller => 'devise/sessions', :as => :user_session do
get :new, :path => 'signin'
post :create, :path => 'signin', :as => ""
get :destroy, :path => 'signout'
end
resource :registration, :only => [:edit, :update, :destroy], :as
=> :user_registration,
:path => 'account', :controller => 'devise/registrations'
scope :controller => 'devise/registrations', :as
=> :user_registration do
get :new, :path => 'signup', :as => "new"
post :create, :path => 'signup', :as => ""
end
end

ericindc

unread,
Aug 30, 2010, 5:20:38 PM8/30/10
to Devise
I am having the same issue with backwards named routes. I use RVM and
have (I think) removed everything for a fresh install. gem list
devise shows 1.1.2, yet I still see the wrong named routes. Is there
something else I need to do for this?

Enrico Bianco

unread,
Aug 30, 2010, 7:51:01 PM8/30/10
to Devise
I'm having trouble as well, and I'm using devise from git in my
Gemfile rather than using a gem.

The devise FailureApp wants new_user_session and my route is
user_session_new. I have the same sort of customization as what Alan
wrote above for my routes.

I've tried creating a fresh gemset and reinstalling all of the gems,
too.

- Enrico B

Alan McCann

unread,
Aug 30, 2010, 8:02:07 PM8/30/10
to Devise
Hi Enrico:

I worked on the route customization to make sure it matched the
behavior before. This is now working for me.

Try this.... I'm sure it can be put more elegantly but I brute forced
the path's and names so they would not get reversed.

devise_for :users, :path => 'account', :skip =>
[:sessions, :registration] do
scope :controller => 'devise/sessions' do
get :new, :path => 'signin', :as => :new_user_session
post :create, :path => 'signin', :as => :user_session
get :destroy, :path => 'signout', :as => :destroy_user_session
end
resource :registration, :only => [:edit, :update, :destroy], :as
=> :user_registration,
:path => 'account', :controller => 'devise/registrations'
scope :controller => 'devise/registrations' do
get :new, :path => 'signup', :as
=> :new_user_registration
post :create, :path => 'signup', :as => :user_registration
get :cancel, :path => 'account/cancel', :as
=> :cancel_user_registration
end
end

Carlos Antonio da Silva

unread,
Aug 30, 2010, 8:09:28 PM8/30/10
to plataforma...@googlegroups.com
So far it's been working just by installing the right Devise version, there are also some issues in Github related to that (all closed).
If any of you is experiencing this issue and have already tried reinstalled everything, I'd ask to push an application to Github showing the issue.
Thanks.

Enrico Bianco

unread,
Aug 30, 2010, 8:17:22 PM8/30/10
to Devise
Yeah, that ended up working for me, but that's quite nasty, yeah. Oh
well, it'll do for now. >_<

ericindc

unread,
Aug 31, 2010, 12:29:04 PM8/31/10
to Devise
I don't understand "installing the right Devise version". If I do a
gem list and it tells me Devise 1.1.2 is installed, do I need
something else?

On Aug 30, 8:09 pm, Carlos Antonio da Silva

Carlos Antonio da Silva

unread,
Aug 31, 2010, 12:40:48 PM8/31/10
to plataforma...@googlegroups.com
What does your Gemfile says? Are you setting it up with devise version 1.1.2? Otherwise it might just pick up wathever is in your Gemfile.lock if you just run bundle install, and that might not be the latest version.

Be sure to try running bundle update, or removing the .lock file and installing everything again, locking Devise to 1.1.2.

ericindc

unread,
Aug 31, 2010, 1:02:32 PM8/31/10
to Devise
I switched back to Rails 3 RC2 and everything works fine again. Is
anyone else experiencing similarly?

ericindc

unread,
Aug 31, 2010, 1:03:32 PM8/31/10
to Devise
Perhaps it is something in how I have my routes setup?

devise_for :user, :skip => [:sessions, :registration, :passwords] do
scope :controller => 'devise/sessions', :as => :user_session do
get :new, :path => 'login'
post :create, :path => 'login', :as => ""
get :destroy, :path => 'logout'
end

scope :controller => 'devise/passwords', :as => :user_password do
get :new, :path => "password/reset", :as => "new"
post :create, :path => "password/update", :as => ""
put :update, :path => "password/update", :as => ""
get :edit, :path => "password/update", :as => "edit"
end

scope :controller => 'registration', :as => :user_registration do
get :new, :path => 'register', :as => "new"
post :create, :path => 'register', :as => ""
get :edit, :path => 'register/edit', :as => "edit"
put :update, :path => 'register', :as => ""
end
end

On Aug 31, 12:29 pm, ericindc <ericmilf...@gmail.com> wrote:

José Valim

unread,
Aug 31, 2010, 1:03:47 PM8/31/10
to plataforma...@googlegroups.com
If you have custom routes, it was a Rails change, not a Devise one. Devise 1.1.2 supports Rails 3.0.0 routes API.

--
José Valim

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

José Valim

unread,
Aug 31, 2010, 1:04:57 PM8/31/10
to plataforma...@googlegroups.com
Yes, you need to rewrite them. Rails 3 RC had different behavior for routes depending if gave a Symbol or String as first parameter. Rails 3.0.0 has that fixed.


--
José Valim

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


Reply all
Reply to author
Forward
0 new messages