Devise: how to migrate users from one project to another - ruby-on-rails

Wondering if anyone tried this before, I'm trying to migrate devise users from one project(postgres) to another(mongoid).
I've created a script with takes users from sql table and create mongo inserts out of it, all was running fine, but for some reason devise on new project not able to auth migrated users.
encrytpted_password field looks ok.
Can someone please advise if I've missed something?

Related

Method for reseting all users in database with Ruby on Rails 4

So I've set up a new authentication process within my website using rails (rails version '4.2.0', sqlite3 database manager, ruby 2.1.1p76) on OSX Mavericks (yes, I still haven't updated yet!). The website as yet is still only local as I'm learning rails.
I have modified the user authentication to utilise a cookies remember me function, but old users can not login, i.e. error Couldn't find User (ActiveRecord::RecordNotFound in WelcomeController#homepage)
Newly created users can.
I was just wondering what the terminal command is to somehow to delete all records of users from the database, so that all new users need to sign up to obtain the remember me functionality...? I can't seem to find the exact answer and I don't want to start messing too much with the database.
Start a rails console by typing
rails c
in the terminal, in your rails application folder (not the app subfolder).
type
User.destroy_all

Devise in rails giving error on heroku

I am using devise with mongoid. App has two devise models users and investors. When I sign-up for each in localhost it works fine but on heroku when I submit form the page get redirects to app/users or app/investors and I got 500 service internal error. In the app the views directory of users and investors are separately defined.
Any guesses?
Finally solved the issue was the mongodb service, they actually reset the password, so I have to change that in mongoid.yml. My advice for people working with service:
1) Start your debugging with config files the username and password before jumping to plugin code. I spend 5 hours in debugging devise internal code and problem was somewhere else.

Created an entry in rails console, but app has no idea it exists

I entered
SiteData.create(site_name: "My Site", url: "http://mysite.com")
in the console, SiteData being one of my models. Now I can write SiteData.find(1) and it will echo back the entry. Great!
I'm using the db table to store all the info about my site, such as the name, the url, the Facebook page, the Google Plus pages, etc. SO I need to access it on every page. Okay, I'll use before_filter in the application controller to make this work, right?
So I went into my app, and in the Application controller, I wrote
before_filter :add_site_data
def add_site_data
#site_data = SiteData.find(1)
end
And I get an error: "Couldn't find SiteData with id=1"
What now????
This might not be the best way to do this. I am brand new to rails. But I'm totally stuck and have no idea what's going on or why here. I installed Postgres locally today and set up the test and dev dbs, but it seems to be working fine since I can still create/read/update/destroy entries from the console.
Please help! I'm going nuts here. I am using Rails 4.0.
Resetting the server fixed it.
If you know you're making entries in your database that aren't reflected when you run your app, reset the server.

Role table gone, Rails Devise on Heroku

am new to rails & this is my first app .. I used devise & CanCan for authentication & authorization & there was a predefined set of roles for every user that I can assign it to ... Working perfectly on my local machine .. once deployed to Heroku & migrated the database everything seemed in place but when I tried to assign a role to a user there was none .
Any idea what's wrong?
I also wanted to disable the sign-up & only allow admins to create users
Thanks in advance
EDIT:
After too much searching I found out that the missing part is the Role table from the rolify gem, for some reason it refuses to migrate on the PostgreSQL/Heroku.
& the issue is raised in this link, still didn't find a solution that worked for me
https://github.com/EppO/rolify/issues/76
You might need to run all the migrations on Heroku. Do this: heroku run rake db:migrate and try again.

Symfony 1.4, sfGuardPlugin with existing user table/model

I have symfony 1.4 installed and had setup my own user model (table). Now, in order to use sfFacebookConnectPlugin, it asks to use sfGuard plugin, so it can easily integrate existing users with facebook account.
Is there a way to use sfGuardPlugin with existing user model ?
OR
is there a better way to implement facebook connect, such that it recognizes the same user (by email), if exists, or creates a new user in the user table with the fb email id and also creates the session.
Thx !
You can use sfGuardPlugin with an existing model, the schema file will be loaded from the plugin's folder and the table names are namespaced in a way that prevents naming collisions.
All you have to do is install the plugin as per its installation instructions and then build your model. To deploy to production you can either copy the SQL that propel generates (in data/sql) and execute it or use a program like Toad for MySQL to generate diff sql upgrade scripts.
Have you tried and failed? I hope I've addressed your concerns.

Resources