Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method `authorize_with' #40

Open
moondos opened this issue Jan 12, 2022 · 6 comments
Open

Undefined method `authorize_with' #40

moondos opened this issue Jan 12, 2022 · 6 comments

Comments

@moondos
Copy link

moondos commented Jan 12, 2022

Hello!

I wanted to use Cancan with Trestle, but it keeps giving me an error message saying : undefined method `authorize_with'

Refering to this line: config.authorize_with cancan: -> { AdminAbility }

Is there any solution?

@spohlenz
Copy link
Member

I need to correct the README there -- it should be config.auth.authorize_with.

@moondos
Copy link
Author

moondos commented Jan 12, 2022

Unfortunately, still doesn't work. The same error message, undefined method.

Somehow even Built-in (DSL) doesn't work, giving: undefined method `authorize'.

I have these versions:
trestle (0.9.5)
trestle-auth (0.4.3)

@spohlenz
Copy link
Member

Make sure you are also using the authorization branch of trestle-auth from GitHub.

In your Gemfile:

gem 'trestle-auth', github: 'TrestleAdmin/trestle-auth', branch: 'authorization'

@moondos
Copy link
Author

moondos commented Jan 12, 2022

Works now, thank you!

@romaingibs13
Copy link

romaingibs13 commented Jan 14, 2022

@spohlenz Hello I have a similar problem as I have this error:
/Users/romaingibassier/code/the-office3/modules/backstage/config/initializers/trestle.rb:135:in 'block in <main>': undefined method 'auth' for #<Trestle::Configuration> (NoMethodError)

I am also using devise i the latest Rails version, we would like to use your solution as Admin interface for our new legacy website, if we can't get around we're gonna choose another solution sadly.

Here is the line that throws an error in the trestle.rb file:

Screenshot 2022-01-14 at 19 02 59

@jakegiangankoda
Copy link

Make sure you are also using the authorization branch of trestle-auth from GitHub.

In your Gemfile:

gem 'trestle-auth', github: 'TrestleAdmin/trestle-auth', branch: 'authorization'

pardon the intrusion with this old discussion,
does this also cover login authorization? I'm currently trying to implement admin role for the user, and cancel the login if the user isn't an admin..

basically before logging in, i'll check the user if they're an admin or not....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants