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.create! end |
#generate_secure_registration_link ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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_team_registration_url(@team, protocol: link_protocol, host: link_host, registration_token: @token ) 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/generators/jobshop/team/team_generator.rb', line 40 def print_secure_registration_link say <<-MESSAGE ### JOBSHOP - IMPORTANT INFORMATION ############################################ Your Jobshop team has been initialized. You may use the following link to complete the setup process. #{@secure_url} This link is valid for 30 minutes from now and will expire at: #{30.minutes.from_now.in_time_zone("Eastern Time (US & Canada)")} Thank you for using Jobshop! ################################################################################ MESSAGE end |
#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 |