Single user model for all namespaces

90 views
Skip to first unread message

romanvbabenko

unread,
May 20, 2012, 12:47:05 AM5/20/12
to Devise
i have a lot of namespaces, a, b, c ... etc.
i want to use one user model for all namespaces without scopes
how i can implement this behavior?

tnx

Carlos Antonio da Silva

unread,
May 20, 2012, 8:52:45 AM5/20/12
to plataforma...@googlegroups.com
Can't you just have a user model and use it?

I think I didn't understand your problem right, please clarify and extend with examples.

-- 
At.
Carlos Antonio

romanvbabenko

unread,
May 20, 2012, 3:27:39 PM5/20/12
to Devise
Yes, i have User model, Rails 3.0.12 && devise 1.3.3
let me show you

routes.rb

namespace :m do
devise_for :users
end

but my current_user is nil for each controller at :m namespace after i
was signed in

On May 20, 3:52 pm, Carlos Antonio da Silva

Carlos Antonio da Silva

unread,
May 20, 2012, 9:01:41 PM5/20/12
to plataforma...@googlegroups.com
I'm sorry, but I have no idea what you're trying to achieve, and what's not working (I may be already sleepy in any case, but..). Please try to make everything clear and with extended examples, otherwise it's really hard to come up with a possible idea of what's going on.

If you are going to use devise for all namespaces, what's the point of having different endpoints for devise? You could just declare it outside all namespaces and make use of it (if I got it right).

-- 
At.
Carlos Antonio

romanvbabenko

unread,
May 21, 2012, 7:27:04 AM5/21/12
to Devise
ups, i see
i want to use devise for each namespace /m/sign_in /sign_in/ admin/
sign_in
bun model should be User and current_user should be accesible for each
namespace

ok, tnx for your help
i will make demo app

On May 21, 4:01 am, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> I'm sorry, but I have no idea what you're trying to achieve, and what's not working (I may be already sleepy in any case, but..). Please try to make everything clear and with extended examples, otherwise it's really hard to come up with a possible idea of what's going on.
>
> If you are going to use devise for all namespaces, what's the point of having different endpoints for devise? You could just declare it outside all namespaces and make use of it (if I got it right).
>
> --
> At.
> Carlos Antonio
>
>
>
>
>
>
>
> On Sunday, May 20, 2012 at 4:27 PM, romanvbabenko wrote:
> > Yes, i have User model, Rails 3.0.12 && devise 1.3.3
> > let me show you
>
> > routes.rb
>
> > namespace :m do
> > devise_for :users
> > end
>
> > but my current_user is nil for each controller at :m namespace after i
> > was signed in
>
> > On May 20, 3:52 pm, Carlos Antonio da Silva

Andrey Voronkov

unread,
May 21, 2012, 7:45:10 AM5/21/12
to plataforma...@googlegroups.com
Looks like you want authorization for each namespace without authorization system (like cancan):

before_filter :authenticate_admin!

  alias_method :current_admin, :current_user

  private

  def authenticate_admin!
    authenticate_user!
    if current_user && !current_user.is_admin? # Implementation of is_admin? is your responsibility.
      throw(:warden)
    end
  end

2012/5/21 romanvbabenko <romanv...@gmail.com>
Silva

romanvbabenko

unread,
May 21, 2012, 8:13:36 AM5/21/12
to Devise
> Looks like you want authorization for each namespace without authorization
> system (like cancan):

no, i don't

i want devise based authentication system without model name based
authorization
seems like Authlogic https://github.com/binarylogic/authlogic
> 2012/5/21 romanvbabenko <romanvbabe...@gmail.com>
>
>
>
>
>
>
>
> > Silva

Carlos Antonio da Silva

unread,
May 21, 2012, 8:17:05 AM5/21/12
to plataforma...@googlegroups.com
I think what you want is:

devise_for :namespace_a, class_name: 'User'
devise_for :namespace_b, class_name: 'User'


-- 
At.
Carlos Antonio

Reply all
Reply to author
Forward
0 new messages