Class: SocialFramework::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/social_framework/install_generator.rb

Overview

Generator to add the principal files and configurations

Instance Method Summary collapse

Instance Method Details

#add_devise_routesObject

Add devise routes to app maped to framework controllers



26
27
28
29
30
31
32
33
# File 'lib/generators/social_framework/install_generator.rb', line 26

def add_devise_routes
	devise_route = "devise_for :users, class_name: 'SocialFramework::User',\n" <<
    "\t\tcontrollers: {sessions: 'users/sessions',\n"<<
    "\t\t\t\t\t\t\t\t\tregistrations: 'users/registrations',\n"<<
    "\t\t\t\t\t\t\t\t\tpasswords: 'users/passwords'}"
  
  route devise_route
end

#add_viewsObject

Add the principal devise views (registrations and sessions), whith this it’s possible register, update and authenticate users



37
38
39
40
41
# File 'lib/generators/social_framework/install_generator.rb', line 37

def add_views
  directory "views/registrations", "app/views/devise/registrations"
  directory "views/sessions", "app/views/devise/sessions"
  directory "views/shared", "app/views/devise/shared"
end

#copy_devise_setupObject

Copy devise.rb file to app, this file is used to define devise configurations



16
17
18
# File 'lib/generators/social_framework/install_generator.rb', line 16

def copy_devise_setup
  copy_file "initializers/devise.rb", "config/initializers/devise.rb"
end

#copy_social_framework_setupObject

Copy social_framework.rb file to app, this file is used to define social_framework configurations



11
12
13
# File 'lib/generators/social_framework/install_generator.rb', line 11

def copy_social_framework_setup
  copy_file "initializers/social_framework.rb", "config/initializers/social_framework.rb"
end

#copy_translate_fileObject

Copy translate file to app, this file is used to define devise configurations



21
22
23
# File 'lib/generators/social_framework/install_generator.rb', line 21

def copy_translate_file
  copy_file "../../../config/locales/devise.en.yml", "config/locales/devise.en.yml"
end