Undefined method 'devise' when including User model outside Rails
Even though this architecture must change in the near future, we managed to work around this error by including devise and its initializer in the ruby application.
# FIXME: Dependency needed in Rails but not in the engine.
require 'devise'
require_relative "../../RailsApp/config/initializers/devise.rb"
#Load all the models
`method_missing': undefined method `devise' for User (call 'User.connection' to establish a connection)
This happens because you missed the command:
rails generate devise:install
You need just comment all devise lines temporally (in routes.rb / user.rb) to not get raise.
And run command again.
Rails error : undefined method `product' for #User:0x00007faaa8c42700 Did you mean? products products=
You have left behind an old validation in your user model.
Delete this line in the app/models/user.rb filevalidates_length_of :product, maximum: 10
Add trackable (devise) to existing User model?
The Trackable
module expects more than just the sign_in_count
attribute.
The full list of required columns is listed in the documentation
If you add another migration for the remaining columns, everything should work as expected.
Rails 3 + Devise: user_signed_in? for a different user in the database?
I'm not the author of Devise, but from what I can tell of Warden / Devise neither keep track of who is logged in.
The problem with having an is_online column in the User table is that it is difficult to see who is active on the website. I would add a column to your User model called last_seen as a date-time, and update that with Devise every time the user requests a page. You could then easily add a User.online_count method or also see if a user has been seen at the website in the last 5 minutes.
Related Topics
Package Configuration for Libffi Is Not Found in MACos While Installing Travis-Cli
Ruby on Rails:How to Implement Cancel Button in Form_Tag
How to Completely Remove Webpack and All Its Dependencies from Rails App
Ruby/Rails - How to Create a Class and Access It from the Controller
Why Is a String Key for a Hash Frozen
Issues with Has_Many :Through, Cache, Touch and Counter_Cache
How to Return Everything After Last Slash(/) in a Ruby String
Naming Conventions for Boolean Attributes
List of Ruby Metaprogramming Methods
Ruby, How to Add a Param to an Url That You Don't Know If It Has Any Other Param Already
How to Join a Table and Count Records in Rails 3
How to Download a Ruby Gem Without Installing It Automatically
Using Ruby CSV to Extract One Column
Use Same Controller for Multiple Routes
How to Get Rufus-Scheduler Working with a Rails App Deployed to Heroku