Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6138401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:51:57+00:00 2026-05-23T17:51:57+00:00

I am using Devise in Rails 3, and have a User model in rails

  • 0

I am using Devise in Rails 3, and have a User model in rails that is starting to get kinda crowded.. so I would like to put all of the login meethods inside of a module and include them from my model. I’m trying something like:

app/model/user.rb

class User < ActiveRecord::Base
  include UserImageable
  extend Loginable

  has_one  :profile, :dependent => :destroy
  has_many :items, :dependent => :destroy
  has_many :products, :through => :items

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me, :first_name, :last_name, :phone_number, :location, :photo, :profile_attributes, :access_token
  delegate :first_name, :last_name,  :phone_number, :phone_number=, :location, :location=, :photo,  :to  => :profile

  accepts_nested_attributes_for :profile
end

and

lib/autoloads/loginable.rb

module Loginable
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable

  def password_require?
    new_record?
  end
end

but the server doesn’t seem to like that, as it loads with a NoMeethodError

loginable.rb:4:in `<module:Loginable>': undefined method `devise' for Loginable:Module (NoMethodError)

Is there a way to do what I’m shooting for, or not really?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:51:57+00:00Added an answer on May 23, 2026 at 5:51 pm

    This is not the answer you are looking for but, here is my 2 cents: You shouldn’t put all that stuff in the User model. devise models have a clear responsibility: signing.

    But if you really want to put everything hooked in User.rb, you can split the model in extensions (partially enabling DCI):

    Add that to your lib/models/{modelname}/devise_ext.rb

    module Models
        module User
            module DeviseExt
                extend ActiveSupport::Concern
    
                included do
                            devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable
    
                end
    
                module ClassMethods
    
                end
    
                module InstanceMethods      
    
                    def password_require?
                                    new_record?
                                end
                end #InstanceMethods
    
            end
        end
    end
    

    Then, you just add it into your model:

    include Models::User::DeviseExt
    

    In the app we have in my company we actually have no code at all in models, we put everything in extensions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails 3 app that is currently using Devise for authentication. I
I am relatively new to Rails. I have a User model through Devise. I
I have a Rails 3 App using devise. I want to create a User/Profile
I'm building an app in Rails 3. I currently have a user model which
I'm using Devise as authenticating solution in Rails and I have a cached fragment
I'm using Rails 3 with devise. I have a table books which has a
I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using
I have a Rails site that uses Devise for authentication. I have one page
I have a very simple rails 3 program with 2 models: a user model
I have an app that's a simple clone of reddit. Using Devise you can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.