Class: Somatics::Generators::AuthenticatedGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Extended by:
TemplatePath
Defined in:
lib/generators/somatics/authenticated/authenticated_generator.rb

Instance Method Summary collapse

Methods included from TemplatePath

source_root

Instance Method Details

#add_fields_to_devise_modelObject



16
17
18
19
20
21
22
23
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 16

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_modelObject



12
13
14
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 12

def create_devise_model
  invoke 'devise'
end

#create_sessions_controllerObject



38
39
40
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 38

def create_sessions_controller
  invoke 'somatics:authenticated_controller'
end

#modify_devise_model_formObject



34
35
36
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 34

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_routeObject



42
43
44
45
46
47
# File 'lib/generators/somatics/authenticated/authenticated_generator.rb', line 42

def modify_devise_route
  inject_into_file File.join('config/routes.rb'), :after => "devise_for :#{table_name}" do
    session_controller = ((options.namespace.blank? ? [] : [options.namespace]) << "#{name}_sessions").join('/')
    ", :path => '#{options.namespace}', :controllers => {:sessions => '#{session_controller}'}"
  end
end