Class: Godmin::AuthenticationGenerator
- Inherits:
-
Generators::NamedBase
- Object
- Rails::Generators::Base
- Generators::Base
- Generators::NamedBase
- Godmin::AuthenticationGenerator
- Defined in:
- lib/generators/godmin/authentication/authentication_generator.rb
Instance Method Summary collapse
- #create_model ⇒ Object
- #create_route ⇒ Object
- #create_sessions_controller ⇒ Object
- #modify_application_controller ⇒ Object
- #modify_model ⇒ Object
Methods inherited from Generators::Base
Instance Method Details
#create_model ⇒ Object
6 7 8 |
# File 'lib/generators/godmin/authentication/authentication_generator.rb', line 6 def create_model generate "model", "#{name} email:string password_digest:text --no-test-framework" end |
#create_route ⇒ Object
22 23 24 |
# File 'lib/generators/godmin/authentication/authentication_generator.rb', line 22 def create_route route "resource :session, only: [:new, :create, :destroy]" end |
#create_sessions_controller ⇒ Object
26 27 28 |
# File 'lib/generators/godmin/authentication/authentication_generator.rb', line 26 def create_sessions_controller template "sessions_controller.rb", File.join("app/controllers", namespaced_path, "sessions_controller.rb") end |
#modify_application_controller ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/godmin/authentication/authentication_generator.rb', line 30 def modify_application_controller inject_into_file File.join("app/controllers", namespaced_path, "application_controller.rb"), after: "Godmin::ApplicationController\n" do <<-END.strip_heredoc.indent(namespace ? 4 : 2) include Godmin::Authentication def admin_user_class #{class_name} end END end end |
#modify_model ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/godmin/authentication/authentication_generator.rb', line 10 def modify_model inject_into_file File.join("app/models", class_path, "#{file_name}.rb"), after: "ActiveRecord::Base\n" do <<-END.strip_heredoc.indent(namespace ? 4 : 2) include Godmin::Authentication::User def self.login_column :email end END end end |