Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to rename Devise Model name in ruby on rails

We had 2 ruby on rails apps that one was using json outputs from the other. But we decided to integrate them which ran into a lot of issues.

The issue now is, the writer of one system used to 'devise' gem for all user authentication and registration, which was fine. But when we had to integrate them it caused problems, because the other system also had a model named users, which was not used for this purpose.

And it would be A LOT easier to just rename the devise user model to something like "site-user" which im currently trying. Than re-name the other model.

I tried renaming everything that relates to devise in all the files to siteuser instead of user but still getting errors. Anyone have any advice on this. If i can just get this devise user to use a different model name than "User" i will be able to make a lot of progress but this is proving quite the annoyance.

Current error is

NoMethodError in Devise::Sessions#new - highlighting the line with "if user_signed_in"

    <li>
    <%= link_to t('nav.support'), 'http://banana.sweatervest.net/' %>
    </li>
    <%- if user_signed_in? -%>
    <%- if controller_name != 'dashboard' -%>
    <li>
    <%= link_to t('nav.dashboard'), :dashboard %>
like image 835
Spungey Avatar asked Dec 09 '22 11:12

Spungey


1 Answers

Why not uninstall it and then reinstall the model.

First:

 rails destroy devise User

then:

rails generate devise whateveryourmodelnamehere

Much easier than trying to rename everything, only because I've been there ;)

like image 180
Shaun Frost Duke Jackson Avatar answered Dec 25 '22 17:12

Shaun Frost Duke Jackson