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

Rolify doesn't work inside engines #238

Closed
ghost opened this issue Mar 27, 2014 · 18 comments
Closed

Rolify doesn't work inside engines #238

ghost opened this issue Mar 27, 2014 · 18 comments

Comments

@ghost
Copy link

ghost commented Mar 27, 2014

I have devise setup inside of my engine, however, the Rolify generates do not work inside the engine.

rails g rolify Role User
error: "uninitialized constant User"

So I then just created the necessary files without the generator. I would then get an error on rake db:migrate stating "uninitialized constant Role".

So I put: require 'rolify'
inside of my engine.rb file.

Still nothing. What's wrong?

@mido18
Copy link
Contributor

mido18 commented Apr 12, 2014

you can use this repo https://github.com/mido18/rolify this problem fixed in it.
I requested a merging request let's hope the owner will accept it soon :)

@Svashta
Copy link

Svashta commented Apr 3, 2015

Is this still not merged?

@mido18
Copy link
Contributor

mido18 commented Apr 3, 2015

@Svashta i think its still not merged

@wldcordeiro
Copy link
Member

@mido18 What PR is it? Can you link to it and is it working against the current codebase?

@samuelralak
Copy link

I am the same problem here. @mido18 what is causing this problem and what was the fix?

@wldcordeiro
Copy link
Member

@mido18 there is no open or closed PR from you here, could you try creating one against the current repo head?

@mido18
Copy link
Contributor

mido18 commented Sep 25, 2015

@wldcordeiro Sorry what is PR ? also i don't know if it's working on the current codebase
@samuelralak The fix is in this link
mido18@c7b4bc3

@wldcordeiro
Copy link
Member

A PR is a pull request, your fix is over a hundred commits behind the Rolify upstream. I could take a look and see if it works with our current code base but if you could pull down changes from upstream and create a pull request it'd help a lot.

@mido18
Copy link
Contributor

mido18 commented Sep 25, 2015

@wldcordeiro okay i will try to do it :)

@wldcordeiro
Copy link
Member

Hmm it actually looks like I've already integrated your changes into the project at some point but the issue is still present.
https://github.com/RolifyCommunity/rolify/blob/master/lib/generators/active_record/rolify_generator.rb#L16

@mido18
Copy link
Contributor

mido18 commented Sep 25, 2015

@wldcordeiro i think you must pass "engine" and "devise" as args when you use
"rails g rolify Role User" so the generator will be something like this
"rails g rolify Role User engine devise"

@mido18
Copy link
Contributor

mido18 commented Sep 25, 2015

@wldcordeiro
I added this to gem documentation on my fork

  1. Generate Role Model

First, create your Role model and migration file using this generator:

rails g rolify Role User
if you use rolify inside eninge your generator:

rails g rolify Role User engine
if your user model have devise dependency then your generator:

rails g rolify Role User engine devise

@wldcordeiro
Copy link
Member

Ah, I see. That needs to be added to the docs somewhere. 😄 I'll figure that out and add that.

@wldcordeiro
Copy link
Member

@samuelralak the solution has been posted if you're on the newest version of Rolify.

@mido18
Copy link
Contributor

mido18 commented Sep 25, 2015

@wldcordeiro Cool 👍

@EppO
Copy link
Member

EppO commented Oct 15, 2015

@wldcordeiro: can you please point out the commit or the wiki page regarding that issue in order to close it?

@mhoad
Copy link

mhoad commented Mar 27, 2018

Just wanted to let people know that rails g rolify Role User engine devise no longer appears to work. The correct method for ensuring Rolify works within a mounted engine is

  1. Add rolify to your gemspec with
    s.add_dependency 'rolify', '~> 5.2'
  2. Run the generator as such
    bin/rails generate rolify Role YourEngineName::User
  3. Add the following to your user.rb file
    rolify role_cname: 'YourEngineName::Role'
  4. Add the following to lib/yourenginename.rb
    require 'rolify'

@EppO
Copy link
Member

EppO commented Feb 28, 2019

Added Engine configuration steps in wiki, thanks!

@EppO EppO closed this as completed Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants