Class: Jobshop::Generators::TeamGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Jobshop::Generators::TeamGenerator
- Defined in:
- lib/generators/jobshop/team/team_generator.rb
Instance Method Summary collapse
- #create_team ⇒ Object
- #generate_secure_registration_link ⇒ Object
- #generate_token ⇒ Object
- #print_secure_registration_link ⇒ Object
- #require_environment ⇒ Object
Instance Method Details
#create_team ⇒ Object
18 19 20 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 18 def create_team @team = ::Jobshop::Team.new end |
#generate_secure_registration_link ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 26 def generate_secure_registration_link link_protocol = Rails.env.development? ? "http" : "https" link_host = Rails.env.development? ? "localhost:3000" : "YOUR-HOST-NAME" # TODO: Give environments besides development a decent host and # protocol. HTTPS isn't mandatory in production but it is very, VERY # highly recommended. @secure_url = ::Jobshop::Engine.routes.url_helpers. new_welcome_registration_url( protocol: link_protocol, host: link_host, registration_token: @token, team_id: @team.id ) end |
#generate_token ⇒ Object
22 23 24 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 22 def generate_token @token = @team.generate_registration_token end |
#print_secure_registration_link ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 41 def print_secure_registration_link say "### JOBSHOP - IMPORTANT INFORMATION ############################################\n\nYour Jobshop team has been initialized.\nYou may use the following link to complete the setup process.\n\n\#{@secure_url}\n\nThis link is valid for 30 minutes and will expire at:\n\#{30.minutes.from_now.in_time_zone(\"Eastern Time (US & Canada)\")}\n\nThank you for using Jobshop!\n\n################################################################################\n MESSAGE\nend\n" |
#require_environment ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 8 def require_environment ENV["RAILS_ENV"] ||= "development" abort "Please run this command within a Rails app." unless Rails.root environment_filename = File.( Rails.root + "config/environment.rb") require environment_filename end |