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

Already on GitHub? Sign in to your account

Problems with multiple Devise Models (not all invitable) #203

jfeust opened this Issue Apr 19, 2012 · 0 comments


None yet
2 participants

jfeust commented Apr 19, 2012

Basically I have two completely separate devise models in my app. Users are :invitable. Reps are not :invitable. Both have their own Registation controller: Users::RegistrationsController and Reps::RegistrationsController.

The problem I'm encountering is that lib/devise_invitable/controllers/registrations.rb is injecting the destroy_if_previously_invited method into my non invitable Reps::RegistrationsController. Thus line 28 is being called:

resource = resource_class.where(:email => hash[:email], :invited_by_id => nil).first

But Reps does not have an "invited_by_id" field so I get the following error

ActiveRecord::StatementInvalid: PG::Error: ERROR: column reps.invited_by_id does not exist 

I'm not sure what determines if the "destroy_if_previously_invited" method gets injected into the Devise Registration controller, but there should be a way to say "this devise model (and controllers) are not invitable, so don't inject these additional methods".

My current hacky fix is to overwrite the "destroy_if_previously_invited" method in Reps::RegistrationsController

# overwrite to fix devise invitable issue
def destroy_if_previously_invited

@scambra scambra closed this in f9255b7 Apr 23, 2012

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