Class: OauthBundle::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- OauthBundle::Generators::InstallGenerator
- Defined in:
- lib/generators/oauth_bundle/install/install_generator.rb
Instance Method Summary collapse
- #add_devise_omniauth_to_user_model ⇒ Object
- #add_omniauth_to_devise_file ⇒ Object
- #create_migration_for_auth_model ⇒ Object
- #generate_omniauth_callback_controllers ⇒ Object
-
#install_devise_auth_model ⇒ Object
public method will be run automatically.
Instance Method Details
#add_devise_omniauth_to_user_model ⇒ Object
31 32 33 34 |
# File 'lib/generators/oauth_bundle/install/install_generator.rb', line 31 def add_devise_omniauth_to_user_model inject_str = " devise :omniauthable, :omniauth_providers => [:facebook, :twitter, :github]\n" inject_into_file "app/models/user.rb", inject_str, :after => ":validatable\n" end |
#add_omniauth_to_devise_file ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/oauth_bundle/install/install_generator.rb', line 21 def add_omniauth_to_devise_file @providers = [:github, :facebook, :twitter] inject_str = @providers.map do |e| " config.omniauth :#{e}, 'APP_ID', 'APP_SECRET'" end.join("\n") + "\n" inject_into_file "config/initializers/devise.rb", inject_str, :after => "scope: 'user,public_repo'\n" end |
#create_migration_for_auth_model ⇒ Object
16 17 18 19 |
# File 'lib/generators/oauth_bundle/install/install_generator.rb', line 16 def create_migration_for_auth_model system "rails g migration AddColumnsTo#{@auth_model.capitalize} provider uid" system "rake db:migrate" end |
#generate_omniauth_callback_controllers ⇒ Object
36 37 38 39 40 |
# File 'lib/generators/oauth_bundle/install/install_generator.rb', line 36 def generate_omniauth_callback_controllers path = "app/controllers/#{@auth_model}/omniauth_callbacks_controller.rb" create_file path append_file path, omniauth_callback_contrllers_content end |
#install_devise_auth_model ⇒ Object
public method will be run automatically.
7 8 9 10 11 12 13 14 |
# File 'lib/generators/oauth_bundle/install/install_generator.rb', line 7 def install_devise_auth_model model = ask "Please provide authentication model name (default: users):" model = (model.empty? ? "users" : model).tableize @auth_model = model install_devise model config_devise_routes model end |