Does not work properly with STI (single table inheritance) #195

Closed
bkirby opened this Issue Apr 12, 2010 · 9 comments

Comments

Projects
None yet
2 participants
@bkirby

bkirby commented Apr 12, 2010

I'm using rails 3 beta2, and I've tried both the master branch, and 1.1.rc0. When I use devise_for in my routes, the routes are never created. 'rake routes' never shows any session/devise related routes, just those that I've created.

It doesn't throw any errors or break anything, the routes just don't come through. I have to manually set them for them to work.

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Apr 12, 2010

Owner

That's odd. Could you please pastie your routes and Gemfile?

Owner

josevalim commented Apr 12, 2010

That's odd. Could you please pastie your routes and Gemfile?

@bkirby

This comment has been minimized.

Show comment Hide comment
@bkirby

bkirby Apr 12, 2010

Thanks for looking at it.

A couple notes. I'm doing some craziness with the routes, mapping anything missing to pages#show (its a pretty dynamic cms). I thought maybe my namespace or routes were messing with it, so I tried removing everything but root :to and the devise_for line but still had no success.

I also know that you guys dropped support for mongo_mapper, so I just used the devise/orm/mongo_mapper from the version prior to master. It is actually working fine (creating passwords correctly etc).

Here are my routes and Gemfile
http://pastie.org/915871

Here is the output from 'rake routes'
http://pastie.org/915878

bkirby commented Apr 12, 2010

Thanks for looking at it.

A couple notes. I'm doing some craziness with the routes, mapping anything missing to pages#show (its a pretty dynamic cms). I thought maybe my namespace or routes were messing with it, so I tried removing everything but root :to and the devise_for line but still had no success.

I also know that you guys dropped support for mongo_mapper, so I just used the devise/orm/mongo_mapper from the version prior to master. It is actually working fine (creating passwords correctly etc).

Here are my routes and Gemfile
http://pastie.org/915871

Here is the output from 'rake routes'
http://pastie.org/915878

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Apr 12, 2010

Owner

Mongomapper is not supposed to modify the routing part, so this is not the cause.

Actually, I cannot see anything in both Gemfile and config/routes.rb that could be causing the issue. Thus I need to ask you to try to isolate this issue in a smaller application that you can publish in Github.

Thanks!

Owner

josevalim commented Apr 12, 2010

Mongomapper is not supposed to modify the routing part, so this is not the cause.

Actually, I cannot see anything in both Gemfile and config/routes.rb that could be causing the issue. Thus I need to ask you to try to isolate this issue in a smaller application that you can publish in Github.

Thanks!

@bkirby

This comment has been minimized.

Show comment Hide comment
@bkirby

bkirby Apr 12, 2010

Yeah thats what I was thinking as well.

After creating a fresh project, I think I've narrowed it down. My admin model was extending user (sti). Using devise_for :users works as expected. I went back and added the devise (w/options) method to my admin model as well and that cleared it up.

Seems it wasn't inheriting from the User model. Wouldn't consider that a problem really, but it would be useful if it did :)

Thanks again.

bkirby commented Apr 12, 2010

Yeah thats what I was thinking as well.

After creating a fresh project, I think I've narrowed it down. My admin model was extending user (sti). Using devise_for :users works as expected. I went back and added the devise (w/options) method to my admin model as well and that cleared it up.

Seems it wasn't inheriting from the User model. Wouldn't consider that a problem really, but it would be useful if it did :)

Thanks again.

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Apr 12, 2010

Owner

Just to be sure: the problem is that when using STI, the models you specify are not copied from parent to child. Is that it?

If so, I think I can see how this is bug and I know a simple solution. :)

Owner

josevalim commented Apr 12, 2010

Just to be sure: the problem is that when using STI, the models you specify are not copied from parent to child. Is that it?

If so, I think I can see how this is bug and I know a simple solution. :)

@bkirby

This comment has been minimized.

Show comment Hide comment
@bkirby

bkirby Apr 12, 2010

Yep exactly. In order for the STI models to work, you have to re-declare the devise method in your child models.

Heres a better explanation:

http://pastie.org/915925

bkirby commented Apr 12, 2010

Yep exactly. In order for the STI models to work, you have to re-declare the devise method in your child models.

Heres a better explanation:

http://pastie.org/915925

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Apr 12, 2010

Owner

Sweet! I will fix it! :D
I will change the title of the ticket as well, so it's more information!

Thanks!

Owner

josevalim commented Apr 12, 2010

Sweet! I will fix it! :D
I will change the title of the ticket as well, so it's more information!

Thanks!

@bkirby

This comment has been minimized.

Show comment Hide comment
@bkirby

bkirby Apr 12, 2010

No problem. Devise has been awesome! Glad to help.

bkirby commented Apr 12, 2010

No problem. Devise has been awesome! Glad to help.

@josevalim

This comment has been minimized.

Show comment Hide comment
@josevalim

josevalim Apr 15, 2010

Owner

Fix a bug with STI. Closed by b2a50db.

Owner

josevalim commented Apr 15, 2010

Fix a bug with STI. Closed by b2a50db.

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment