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 local variable or method `rolify' for User #418

Closed
vjustov opened this issue Sep 19, 2016 · 6 comments
Closed

undefined local variable or method `rolify' for User #418

vjustov opened this issue Sep 19, 2016 · 6 comments

Comments

@vjustov
Copy link

vjustov commented Sep 19, 2016

Hello, thank you for the wonderful work, I'm using Rolify with AR in a rails app and suddenly this error started appearing in a commit where I only changed some js, and some other stuff unrelated to rolify. I started debugging the problem and I have isolated the problem to the one line where the Gemfile.lock changes from react-rails from react-rails (1.1.0) to react-rails (1.8.2).

I'm using ruby 2.3.1, rails 4.2.7.1 and rolify 5.1.0. Sadly I couldn't replicate the issue with a new app.
In this gist you can see the conflicting gemfile and gemfile.lock.

Let me know if i need to supply more info.

@vjustov
Copy link
Author

vjustov commented Sep 19, 2016

I fixed the problem by reordering my gemfile, gem "rolify" before gem "react-rails"...
now the question remains:
giphy 1

@cipater
Copy link

cipater commented May 22, 2017

Ran into the same issue after upgrading an existing app from rails 4.2.8 to 5.1.0.

Reordering the Gemfile didn't do anything for my case. However, adding a require 'rolify' to the top of application.rb did the trick:

require File.expand_path('../boot', __FILE__)

require 'rolify'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)

@batmanbury
Copy link

I'm using Rails 5.1.1 with rolify 5.1.0 and seem to have this same issue. None of the above suggestions worked however.

First, after bundle installing, the generators would not appear in the rails g list, so I added the generator files manually to lib and ran them with rails g active_record:rolify Role User. Still, no gem methods work, and going into rails console gives me undefined local variable or method 'rolify'

@ezetadev
Copy link

ezetadev commented Jul 18, 2017

@cipater solution worked for me. Rails 5.1.2 and rolify 5.1.0.

Edit: It didn't Works :(

Edit 2: I can see the web and everything it's ok. However, rake test aborts: "undefined local variable or method `rolify' for User"

@nickrivadeneira
Copy link

I fixed this by adding this line to application.rb:

require 'rolify/railtie'

Reordering the Gemfile was not required. Got the idea from here.

@EppO
Copy link
Member

EppO commented Feb 28, 2019

Added react-rails workaround in the Wiki

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants