goma 0.0.1.beta → 0.0.1.gamma

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +9 -1
  4. data/README.md +18 -15
  5. data/goma.gemspec +16 -0
  6. data/lib/generators/goma/erb/templates/confirmation/new.html.erb +2 -2
  7. data/lib/generators/goma/erb/templates/password/new.html.erb +2 -2
  8. data/lib/generators/goma/erb/templates/session/new.html.erb +3 -3
  9. data/lib/generators/goma/erb/templates/unlock/new.html.erb +2 -2
  10. data/lib/generators/goma/helpers/helpers.rb +5 -0
  11. data/lib/generators/goma/install/templates/goma.rb +38 -22
  12. data/lib/generators/goma/mailer/erb/templates/activation_needed_email.html.erb +1 -1
  13. data/lib/generators/goma/mailer/erb/templates/activation_needed_email.text.erb +1 -1
  14. data/lib/generators/goma/mailer/erb/templates/email_confirmation_needed_email.html.erb +1 -1
  15. data/lib/generators/goma/mailer/erb/templates/email_confirmation_needed_email.text.erb +1 -1
  16. data/lib/generators/goma/mailer/templates/mailer.rb +1 -1
  17. data/lib/generators/goma/model/active_record_generator.rb +11 -0
  18. data/lib/generators/goma/model/oauth/active_record_generator.rb +10 -1
  19. data/lib/generators/goma/model/oauth/templates/model.rb +5 -0
  20. data/lib/generators/goma/resource_route/resource_route_generator.rb +10 -12
  21. data/lib/generators/goma/scaffold_controller/templates/confirmation_controller.rb +5 -5
  22. data/lib/generators/goma/scaffold_controller/templates/oauth_controller.rb +1 -1
  23. data/lib/generators/goma/scaffold_controller/templates/password_controller.rb +2 -2
  24. data/lib/generators/goma/scaffold_controller/templates/session_controller.rb +2 -2
  25. data/lib/generators/goma/scaffold_controller/templates/unlock_controller.rb +1 -1
  26. data/lib/generators/goma/scaffold_controller/templates/user_controller.rb +6 -1
  27. data/lib/goma/config.rb +16 -19
  28. data/lib/goma/models/confirmable.rb +1 -1
  29. data/lib/goma/models/rememberable.rb +2 -2
  30. data/lib/goma/railtie.rb +0 -9
  31. data/lib/goma/version.rb +1 -1
  32. data/test/controllers/confirmations_controller_test.rb +14 -0
  33. data/test/controllers/lockable_controller_test.rb +8 -8
  34. data/test/controllers/sessions_controller_test.rb +8 -8
  35. data/test/controllers/users_controller_test.rb +2 -13
  36. data/test/fabricators/users_fabricator.rb +2 -2
  37. data/test/integration/{authenticatable_test.rb → authenticatable_integration_test.rb} +4 -4
  38. data/test/integration/omniauthable_integration_test.rb +26 -0
  39. data/test/integration/{rememberable_test.rb → rememberable_integration_test.rb} +7 -7
  40. data/test/integration/{routes_test.rb → routes_integration_test.rb} +8 -8
  41. data/test/integration/{timeoutable_test.rb → timeoutable_integration_test.rb} +3 -3
  42. data/test/integration/{trackable_test.rb → trackable_integration_test.rb} +3 -3
  43. data/test/models/confirmable_test.rb +1 -1
  44. data/test/models/validatable_test.rb +7 -7
  45. data/test/rails_app/app/assets/javascripts/{sessions.js → confirmations.js} +0 -0
  46. data/test/rails_app/app/assets/stylesheets/authentications.css +4 -0
  47. data/test/rails_app/app/assets/stylesheets/confirmations.css +4 -0
  48. data/test/rails_app/app/assets/stylesheets/passwords.css +4 -0
  49. data/test/rails_app/app/assets/stylesheets/unlocks.css +4 -0
  50. data/test/rails_app/app/controllers/authentications_controller.rb +15 -0
  51. data/test/rails_app/app/controllers/confirmations_controller.rb +52 -0
  52. data/test/rails_app/app/controllers/passwords_controller.rb +41 -0
  53. data/test/rails_app/app/controllers/sessions_controller.rb +13 -5
  54. data/test/rails_app/app/controllers/unlocks_controller.rb +32 -0
  55. data/test/rails_app/app/controllers/users_controller.rb +32 -15
  56. data/test/rails_app/app/helpers/authentications_helper.rb +2 -0
  57. data/test/rails_app/app/helpers/confirmations_helper.rb +2 -0
  58. data/test/rails_app/app/helpers/passwords_helper.rb +2 -0
  59. data/test/rails_app/app/helpers/unlocks_helper.rb +2 -0
  60. data/test/rails_app/app/mailers/user_mailer.rb +33 -20
  61. data/test/rails_app/app/views/confirmations/new.html.erb +12 -0
  62. data/test/rails_app/app/views/passwords/edit.html.erb +27 -0
  63. data/test/rails_app/app/views/passwords/new.html.erb +11 -0
  64. data/test/rails_app/app/views/sessions/new.html.erb +13 -5
  65. data/test/rails_app/app/views/unlocks/new.html.erb +11 -0
  66. data/test/rails_app/app/views/user_mailer/activation_needed_email.text.erb +5 -2
  67. data/test/rails_app/app/views/user_mailer/activation_success_email.text.erb +7 -2
  68. data/test/rails_app/app/views/user_mailer/email_confirmation_needed_email.text.erb +5 -2
  69. data/test/rails_app/app/views/user_mailer/email_confirmation_success_email.text.erb +4 -2
  70. data/test/rails_app/app/views/user_mailer/reset_password_email.text.erb +10 -0
  71. data/test/rails_app/app/views/user_mailer/unlock_token_email.text.erb +10 -0
  72. data/test/rails_app/app/views/users/_form.html.erb +33 -0
  73. data/test/rails_app/app/views/users/edit.html.erb +6 -2
  74. data/test/rails_app/app/views/users/index.html.erb +25 -2
  75. data/test/rails_app/app/views/users/new.html.erb +5 -2
  76. data/test/rails_app/app/views/users/show.html.erb +4 -2
  77. data/test/rails_app/config/environments/test.rb +2 -0
  78. data/test/rails_app/config/initializers/goma.rb +43 -29
  79. data/test/rails_app/config/initializers/omniauth.rb +4 -0
  80. data/test/rails_app/config/routes.rb +20 -5
  81. data/test/rails_app/db/migrate/20140512081308_create_users.rb +44 -0
  82. data/test/rails_app/db/migrate/{20140326043644_create_authentications.rb → 20140512081309_create_authentications.rb} +1 -0
  83. data/test/rails_app/db/schema.rb +9 -5
  84. data/test/test_helper.rb +10 -0
  85. metadata +72 -24
  86. data/test/rails_app/app/views/user_mailer/unlock_email.text.erb +0 -0
  87. data/test/rails_app/db/migrate/20131205013904_goma_create_users.rb +0 -46
@@ -0,0 +1,15 @@
1
+ class AuthenticationsController < ApplicationController
2
+ before_action
3
+ # GET auth/:provider/callback
4
+ # POST /authentications
5
+ def create
6
+ authentication = Authentication.find_by(provider: omniauth[:provider], uid: omniauth[:uid])
7
+ if authentication
8
+ user = authentication.user
9
+ else
10
+ user = User.create_with_omniauth!(omniauth)
11
+ end
12
+ force_login(user)
13
+ redirect_back_or_to root_url, notice: "Successfully authenticated from #{omniauth[:provider]} account."
14
+ end
15
+ end
@@ -0,0 +1,52 @@
1
+ class ConfirmationsController < ApplicationController
2
+ # GET /confirmations/new
3
+ def new
4
+ @user= User.new
5
+ end
6
+
7
+
8
+ # POST /confirmations
9
+ def create
10
+ @user = User.find_by_identifier(params[:username_or_email])
11
+ @user.generate_confirmation_token
12
+ @user.send_activation_needed_email
13
+
14
+ redirect_to new_session_url, notice: "We are processing your request. You will receive new activation email in a few minutes."
15
+ end
16
+
17
+
18
+ # GET /confirmations/1
19
+ def show
20
+ @user, err = User.load_from_activation_token_with_error(params[:id])
21
+
22
+ if @user
23
+ @user.activate!
24
+ redirect_to new_session_url, notice: 'Your account was successfully activated.'
25
+ else
26
+ if err == :token_expired
27
+ flash.now[:alert] = "Your activation URL has expired, please request a new one."
28
+ else
29
+ flash.now[:alert] = "Not found any account by this URL. Please make sure you used the full URL provided."
30
+ end
31
+ render :new
32
+ end
33
+ end
34
+
35
+
36
+ # GET /confirmations/1/email
37
+ def email
38
+ @user, err = User.load_from_email_confirmation_token_with_error(params[:id])
39
+
40
+ if @user
41
+ @user.confirm_email!
42
+ redirect_to edit_user_url, notice: 'Your new email was successfully confirmed.'
43
+ else
44
+ if err == :token_expired
45
+ flash.now[:alert] = "Your email confirmation URL has expired, please change your email again."
46
+ else
47
+ flash.now[:alert] = "Email confirmation failed. Please make sure you used the full URL provided."
48
+ end
49
+ render edit_user_url(current_user)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,41 @@
1
+ class PasswordsController < ApplicationController
2
+
3
+ # GET /passwords/new
4
+ def new
5
+ @user = User.new
6
+ end
7
+
8
+ # POST /passwords
9
+ def create
10
+ @user = User.find_by_identifier(params[:username_or_email])
11
+ @user.send_reset_password_instructions! if @user
12
+
13
+ flash[:notice] = "You will receive an email with instructions about how to reset your password in a few minutes."
14
+ redirect_to new_session_url
15
+ end
16
+
17
+ # GET /passwords/1/edit
18
+ def edit
19
+ @reset_password_token = params[:id]
20
+ end
21
+
22
+ # PATCH/PUT /passwords/1
23
+ def update
24
+ @user, err = User.load_from_reset_password_token_with_error(params[:id])
25
+
26
+ if @user
27
+ @user.unlock_access! if @user.lockable? && @user.access_locked?
28
+ @user.change_password!(params[:password], params[:password_confirmation])
29
+ force_login(@user)
30
+ redirect_back_or_to root_url, notice: 'Your password was changed successfully. You are now logged in.'
31
+ else
32
+ if err == :token_expired
33
+ flash.now[:alert] = "The password reset URL you visited has expired, please request a new one."
34
+ render :new
35
+ else
36
+ flash.now[:alert] = "You can't access this page without comming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
37
+ render :edit
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,19 +1,27 @@
1
1
  class SessionsController < ApplicationController
2
+
3
+ # GET /sessions/new
2
4
  def new
3
5
  @user = User.new
4
6
  end
5
7
 
8
+ # POST /sessions
6
9
  def create
7
- if @user = login(params[:username_or_email], params[:password], params[:remember_me])
10
+ if @user = user_login(params[:username_or_email], params[:password], params[:remember_me])
8
11
  redirect_back_or_to root_url, notice: 'Login successful'
9
12
  else
10
- flash.now[:alert] = "Login failed"
11
- render action: 'new'
13
+ if goma_error(:user) == :not_activated
14
+ flash.now[:alert] = 'Not activated'
15
+ else
16
+ flash.now[:alert] = 'Login failed'
17
+ end
18
+ render :new
12
19
  end
13
20
  end
14
21
 
22
+ # DELETE /sessions
15
23
  def destroy
16
- logout
17
- redirect_to root_url
24
+ user_logout
25
+ redirect_to root_url, notice: "Logged out!"
18
26
  end
19
27
  end
@@ -0,0 +1,32 @@
1
+ class UnlocksController < ApplicationController
2
+
3
+ # GET /unlocks/1
4
+ def show
5
+ @user, err = User.load_from_unlock_token_with_error(params[:id])
6
+ if @user
7
+ flash[:notice] = "Your account has been unlocked successfully. Please continue to login."
8
+ redirect_to new_session_url
9
+ else
10
+ if err == :token_expired
11
+ flash.now[:alert] = "The unlock URL you visited has expired, please request a new one."
12
+ else
13
+ flash.now[:alert] = "Not found any account by this URL."
14
+ end
15
+ render :new
16
+ end
17
+ end
18
+
19
+ # GET /unlocks/new
20
+ def new
21
+ @user = User.new
22
+ end
23
+
24
+ # POST /unlocks
25
+ def create
26
+ @user = User.find_by_identifier(params[:username_or_email])
27
+ @user.send_unlock_instructions!
28
+
29
+ flash[:notice] = 'Instructions have been sent to your email.'
30
+ redirect_to new_session_url
31
+ end
32
+ end
@@ -1,41 +1,58 @@
1
1
  class UsersController < ApplicationController
2
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /users
2
5
  def index
6
+ @users = User.all
3
7
  end
4
8
 
9
+ # GET /users/1
5
10
  def show
6
11
  end
7
12
 
13
+ # GET /users/new
8
14
  def new
15
+ @user = User.new
16
+ end
17
+
18
+ # GET /users/1/edit
19
+ def edit
9
20
  end
10
21
 
22
+ # POST /users
11
23
  def create
12
24
  @user = User.new(user_params)
25
+
13
26
  if @user.save
14
- flash[:notice] = 'Successfully created'
15
- redirect_to root_url
27
+ redirect_to new_session_url, notice: "You have signed up successfully. However, we could not sign you in because your account is not yet activated. You will receive an email with instructions about how to activate your account in a few minutes."
16
28
  else
17
29
  render :new
18
30
  end
19
31
  end
20
32
 
21
- def activate
22
- @user = User.load_from_activation_token(params[:id])
23
- @user.activate!
24
- flash[:notice] = 'Successfully activated.'
25
- redirect_to root_url
26
- end
27
-
28
- def edit
29
- end
30
-
33
+ # PATCH/PUT /users/1
31
34
  def update
35
+ if @user.update(user_params)
36
+ redirect_to @user, notice: 'User was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
32
40
  end
33
41
 
42
+ # DELETE /users/1
34
43
  def destroy
44
+ @user.destroy
45
+ redirect_to users_url, notice: 'User was successfully destroyed.'
35
46
  end
36
47
 
37
48
  private
38
- def user_params
39
- params.require(:user).permit(:username, :email, :password, :password_confirmation)
40
- end
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_user
51
+ @user = User.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def user_params
56
+ params.require(:user).permit(:username, :email, :password, :password_confirmation)
57
+ end
41
58
  end
@@ -0,0 +1,2 @@
1
+ module AuthenticationsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ConfirmationsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module PasswordsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UnlocksHelper
2
+ end
@@ -1,5 +1,5 @@
1
1
  class UserMailer < ActionMailer::Base
2
- default from: "from@example.com"
2
+ default from: "please-change-me-at-config-initializers-goma@example.com"
3
3
 
4
4
  # Subject can be set in your I18n file at config/locales/en.yml
5
5
  # with the following lookup:
@@ -7,47 +7,60 @@ class UserMailer < ActionMailer::Base
7
7
  # en.user_mailer.activation_needed_email.subject
8
8
  #
9
9
  def activation_needed_email(user)
10
- @greeting = "Hi"
11
-
12
- mail to: "to@example.org"
10
+ @user = user
11
+ mail to: @user.email,
12
+ subject: "Activation instructions"
13
13
  end
14
-
15
14
  # Subject can be set in your I18n file at config/locales/en.yml
16
15
  # with the following lookup:
17
16
  #
18
17
  # en.user_mailer.activation_success_email.subject
19
18
  #
20
19
  def activation_success_email(user)
21
- @greeting = "Hi"
22
-
23
- mail to: "to@example.org"
20
+ @user = user
21
+ mail to: @user.email,
22
+ subject: "Your account is now activated."
24
23
  end
25
-
26
24
  # Subject can be set in your I18n file at config/locales/en.yml
27
25
  # with the following lookup:
28
26
  #
29
27
  # en.user_mailer.email_confirmation_needed_email.subject
30
28
  #
31
29
  def email_confirmation_needed_email(user)
32
- @greeting = "Hi"
33
-
34
- mail to: "to@example.org"
30
+ @user = user
31
+ mail to: @user.email,
32
+ subject: "Email confirmation instructions"
35
33
  end
36
-
37
34
  # Subject can be set in your I18n file at config/locales/en.yml
38
35
  # with the following lookup:
39
36
  #
40
37
  # en.user_mailer.email_confirmation_success_email.subject
41
38
  #
42
39
  def email_confirmation_success_email(user)
43
- @greeting = "Hi"
44
-
45
- mail to: "to@example.org"
40
+ @user = user
41
+ mail to: @user.email,
42
+ subject: "Your email is now changed"
43
+ end
44
+ # Subject can be set in your I18n file at config/locales/en.yml
45
+ # with the following lookup:
46
+ #
47
+ # en.user_mailer.unlock_token_email.subject
48
+ #
49
+ def unlock_token_email(user)
50
+ @user = user
51
+ mail to: @user.email,
52
+ subject: "Unlock instructions"
53
+ end
54
+ # Subject can be set in your I18n file at config/locales/en.yml
55
+ # with the following lookup:
56
+ #
57
+ # en.user_mailer.reset_password_email.subject
58
+ #
59
+ def reset_password_email(user)
60
+ @user = user
61
+ mail to: @user.email,
62
+ subject: "Reset password instructions"
46
63
  end
47
64
 
48
- def unlock_email(user)
49
- @greeting = "Hi"
50
65
 
51
- mail to: "to@example.org"
52
- end
53
66
  end
@@ -0,0 +1,12 @@
1
+ <h1>Resend activation instructions</h1>
2
+
3
+ <%= form_tag(:confirmations_url, method: :post) do %>
4
+ <div class="field">
5
+ <%= label_tag :username_or_email %><br>
6
+ <%= text_field_tag :username_or_email
7
+ </div>
8
+ <div class="actions">
9
+ <%= submit_tag "Resend activation instructions" %>
10
+ </div>
11
+ <% end %>
12
+
@@ -0,0 +1,27 @@
1
+ <h1>Change your password</h1>
2
+
3
+ <%= form_for(@password) do |f| %>
4
+ <% if @password.errors.any? %>
5
+ <div id="error_explanation">
6
+ <h2><%= pluralize(@password.errors.count, "error") %> prohibited this password from being saved:</h2>
7
+
8
+ <ul>
9
+ <% @password.errors.full_messages.each do |msg| %>
10
+ <li><%= msg %></li>
11
+ <% end %>
12
+ </ul>
13
+ </div>
14
+ <% end %>
15
+
16
+ <div class="field">
17
+ <%= f.label :password %><br>
18
+ <%= f.password_field :password %>
19
+ </div>
20
+ <div class="field">
21
+ <%= f.label :password_confirmation %><br>
22
+ <%= f.password_field :password_confirmation %>
23
+ </div>
24
+ <div class="actions">
25
+ <%= f.submit %>
26
+ </div>
27
+ <% end %>
@@ -0,0 +1,11 @@
1
+ <h1>Forget your password?</h1>
2
+
3
+ <%= form_tag(passwords_url, method: :post) do %>
4
+ <div class="field">
5
+ <%= label_tag :username_or_email %><br>
6
+ <%= text_field_tag :username_or_email %>
7
+ </div>
8
+ <div class="actions">
9
+ <%= submit_tag "Send me reset password instructions" %>
10
+ </div>
11
+ <% end %>
@@ -1,19 +1,27 @@
1
1
  <h1>Login</h1>
2
- <%= form_tag session_path do %>
2
+
3
+ <%= form_tag(session_url, method: :post) do %>
3
4
  <div class="field">
4
- <%= label_tag :username_or_email %><br />
5
+ <%= label_tag :username_or_email %><br>
5
6
  <%= text_field_tag :username_or_email %>
6
7
  </div>
7
8
  <div class="field">
8
- <%= label_tag :password %><br />
9
+ <%= label_tag :password %><br>
9
10
  <%= password_field_tag :password %>
10
11
  </div>
12
+
11
13
  <div class="field">
12
- <%= label_tag :remember_me %><br />
13
- <%= check_box_tag :remember_me %>
14
+ <%= check_box_tag :remember_me %> <%= label_tag :remember_me %>
14
15
  </div>
16
+
15
17
  <div class="actions">
16
18
  <%= submit_tag "Login" %>
17
19
  </div>
18
20
  <% end %>
19
21
 
22
+ <% if Rails.env.in? %w(development test) %>
23
+ <%= link_to 'Sign in with Developer', '/auth/developer' %>
24
+ <% end %>
25
+ <%#= link_to 'Sign in with Twitter', '/auth/twitter' %>
26
+ <%#= link_to 'Sign in with Facebook', '/auth/facebook' %>
27
+
@@ -0,0 +1,11 @@
1
+ <h1>Resend unlock instructions</h1>
2
+
3
+ <%= form_tag(unlocks_url, method: :post) do %>
4
+ <div class="field">
5
+ <%= label_tag :username_or_email %><br>
6
+ <%= text_field_tag :username_or_email
7
+ </div>
8
+ <div class="actions">
9
+ <%= submit_tag "Resend unlock instructions" %>
10
+ </div>
11
+ <% end %>
@@ -1,3 +1,6 @@
1
- UserMailer#activation_needed_email
1
+ Welcome, <%= @user.email %>
2
+ ============================================================
2
3
 
3
- <%= @greeting %>, find me in app/views/app/views/user_mailer/activation_needed_email.text.erb
4
+ You can activate your account through the link below:
5
+
6
+ <%= activate_confirmation_url(@user.raw_confirmation_token) %>
@@ -1,3 +1,8 @@
1
- UserMailer#activation_success_email
1
+ Congratz, <%= @user.email %>
2
+ ============================================================
2
3
 
3
- <%= @greeting %>, find me in app/views/app/views/user_mailer/activation_success_email.text.erb
4
+ You have successfully activated your account
5
+
6
+ To login to the site, just follow the link below:
7
+
8
+ <%= new_session_url %>
@@ -1,3 +1,6 @@
1
- UserMailer#email_confirmation_needed_email
1
+ Hello, <%= @user.email %>
2
+ ============================================================
2
3
 
3
- <%= @greeting %>, find me in app/views/app/views/user_mailer/email_confirmation_needed_email.text.erb
4
+ You can confirm your account email through the link below:
5
+
6
+ <%= email_confirmation_url(@user.raw_confirmation_token) %>
@@ -1,3 +1,5 @@
1
- UserMailer#email_confirmation_success_email
1
+ Congratz, <%= @user.email %>
2
+ ============================================================
3
+
4
+ You have successfully changed your account email
2
5
 
3
- <%= @greeting %>, find me in app/views/app/views/user_mailer/email_confirmation_success_email.text.erb
@@ -0,0 +1,10 @@
1
+ Hello, <%= @user.email %>
2
+ ============================================================
3
+
4
+ Someone has requested a link to change your password.
5
+ You can do this through the link below.
6
+
7
+ <%= edit_password_url(@user.raw_reset_password_token) %>
8
+
9
+ If you didn't request this, please ignore this email.
10
+ Your password won't change until you access the link above and create a new one.
@@ -0,0 +1,10 @@
1
+ Hello, <%= @user.email %>
2
+ ============================================================
3
+
4
+ Your account has been locked due to an excessive number of unsuccessful login attempts.
5
+
6
+ Click the link below to unlock your account:
7
+
8
+
9
+ <%= unlock_url(@user.raw_unlock_token) %>
10
+
@@ -0,0 +1,33 @@
1
+ <%= form_for(@user) do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+ <div class="field">
14
+ <%= f.label :username %><br>
15
+ <%= f.text_field :username %>
16
+ </div>
17
+ <div class="field">
18
+ <%= f.label :email %><br>
19
+ <%= f.text_field :email %>
20
+ </div>
21
+ <div class="field">
22
+ <%= f.label :password %><br>
23
+ <%= f.password_field :password %>
24
+ </div>
25
+ <div class="field">
26
+ <%= f.label :password_confirmation %><br>
27
+ <%= f.password_field :password_confirmation %>
28
+ </div>
29
+
30
+ <div class="actions">
31
+ <%= f.submit %>
32
+ </div>
33
+ <% end %>
@@ -1,2 +1,6 @@
1
- <h1>Users#edit</h1>
2
- <p>Find me in app/views/users/edit.html.erb</p>
1
+ <h1>Editing user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @user %> |
6
+ <%= link_to 'Back', users_path %>
@@ -1,2 +1,25 @@
1
- <h1>Users#index</h1>
2
- <p>Find me in app/views/users/index.html.erb</p>
1
+ <h1>Listing users</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+ </thead>
11
+
12
+ <tbody>
13
+ <% @users.each do |user| %>
14
+ <tr>
15
+ <td><%= link_to 'Show', user %></td>
16
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
17
+ <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
18
+ </tr>
19
+ <% end %>
20
+ </tbody>
21
+ </table>
22
+
23
+ <br>
24
+
25
+ <%= link_to 'New User', new_user_path %>
@@ -1,2 +1,5 @@
1
- <h1>Users#new</h1>
2
- <p>Find me in app/views/users/new.html.erb</p>
1
+ <h1>New user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', users_path %>
@@ -1,2 +1,4 @@
1
- <h1>Users#show</h1>
2
- <p>Find me in app/views/users/show.html.erb</p>
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <%= link_to 'Edit', edit_user_path(@user) %> |
4
+ <%= link_to 'Back', users_path %>
@@ -33,4 +33,6 @@ RailsApp::Application.configure do
33
33
 
34
34
  # Print deprecation notices to the stderr.
35
35
  config.active_support.deprecation = :stderr
36
+
37
+ config.action_mailer.default_url_options = { host: 'localhost:3000' }
36
38
  end