Class: Somatics::Generators::AuthenticatedGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Somatics::Generators::AuthenticatedGenerator
- Extended by:
- TemplatePath
- Defined in:
- lib/generators/somatics/authenticated/authenticated_generator.rb
Instance Method Summary collapse
- #add_fields_to_devise_model ⇒ Object
- #create_devise_model ⇒ Object
- #create_sessions_controller ⇒ Object
- #modify_devise_model_form ⇒ Object
- #modify_devise_route ⇒ Object
- #modify_devise_validation ⇒ Object
Methods included from TemplatePath
Instance Method Details
#add_fields_to_devise_model ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 30 def add_fields_to_devise_model invoke "migration", [%(add_name_to_#{table_name}), "name:string"] if File.exists?("app/models/#{singular_name}.rb") inject_into_file "app/models/#{singular_name}.rb", :after => ":remember_me" do ", :name" end end end |
#create_devise_model ⇒ Object
12 13 14 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 12 def create_devise_model invoke 'devise' end |
#create_sessions_controller ⇒ Object
52 53 54 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 52 def create_sessions_controller invoke 'somatics:authenticated_controller' end |
#modify_devise_model_form ⇒ Object
48 49 50 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 48 def modify_devise_model_form template "partial_form.html.erb", File.join('app/views', 'admin', class_path, plural_name, "_form.html.erb"), :force => true end |
#modify_devise_route ⇒ Object
56 57 58 59 60 61 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 56 def modify_devise_route inject_into_file File.join('config/routes.rb'), :after => "devise_for :#{table_name}" do session_controller = ((.namespace.blank? ? [] : [.namespace]) << "#{name}_sessions").join('/') ", :path => '#{.namespace}', :controllers => {:sessions => '#{session_controller}'}" end end |
#modify_devise_validation ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 16 def modify_devise_validation if File.exists?("app/models/#{singular_name}.rb") inject_into_file "app/models/#{singular_name}.rb", :before => " # Setup accessible" do <<-RUBY def password_required? return false if !new_record? && password.blank? && password_confirmation.blank? super end RUBY end end end |