Module: RegistrationGenerator

Defined in:
lib/registration_generator.rb,
lib/registration_generator/version.rb,
lib/registration_generator/generators/registration/registration_generator.rb

Defined Under Namespace

Classes: Error, RegistrationGenerator

Constant Summary collapse

VERSION =
"0.2.2"

Instance Method Summary collapse

Instance Method Details

#add_name_method_to_userObject



54
55
56
57
58
59
60
61
62
# File 'lib/registration_generator/generators/registration/registration_generator.rb', line 54

def add_name_method_to_user
  inject_into_class "app/models/user.rb", User, "\n  def name\n    email_address\n  end\n\n  RUBY\nend\n"

#create_helperObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/registration_generator/generators/registration/registration_generator.rb', line 28

def create_helper
  create_file "app/helpers/authentication_helper.rb", "module AuthenticationHelper\n  def link_to_sign_in_or_out(show_user: false)\n    if authenticated?\n      button_to \"Sign Out\", sign_out_path, method: :delete\n    else\n      link_to \"Sign In\", sign_in_path\n    end\n  end\n\n  def show_username_if_signed_in(text=\"Signed in as\")\n    if authenticated?\n      content = \"\#{text} \#{Current.user.name}\"\n      content.html_safe\n    end\n  end\nend\n  RUBY\n\n  inject_into_class \"app/controllers/application_controller.rb\", ApplicationController, <<-RUBY\n\n  include AuthenticationHelper\n  RUBY\nend\n"