fix: correct typos and improve logout link

- Change "Log out" link to use `data: { turbo_method: :delete }`
- Update "Login in" to "Log in" for consistency
- Fix typo in sign-up prompt from "SIgn up now!" to "Sign up now!"
- Ensure proper indentation in error messages partial
- Add turbo frame to user signup form for better performance
- Adjust routes for consistency by adding leading slashes

These changes enhance the user interface by correcting typographical errors and improving the logout functionality. The use of turbo frames in the signup form aims to optimize the user experience during account creation.
This commit is contained in:
songtianlun 2025-01-02 15:17:27 +08:00
parent d795de6aa1
commit a69a4a5177
6 changed files with 19 additions and 17 deletions

View File

@ -28,12 +28,12 @@
<li><%= link_to "Settings", '#' %></li> <li><%= link_to "Settings", '#' %></li>
<li class="divider"></li> <li class="divider"></li>
<li> <li>
<%= link_to "Log out", logout_path, method: :delete %> <%= link_to "Log out", logout_path, data: { turbo_method: :delete } %>
</li> </li>
</ul> </ul>
</li> </li>
<% else %> <% else %>
<li><%= link_to "Login in", login_url %></li> <li><%= link_to "Log in", login_path %></li>
<% end %> <% end %>
</ul> </ul>
</nav> </nav>

View File

@ -13,6 +13,6 @@
<%= f.submit "Log in", class: "btn btn-primary" %> <%= f.submit "Log in", class: "btn btn-primary" %>
<% end %> <% end %>
<p>New user? <%= link_to "SIgn up now!", signup_path %></p> <p>New user? <%= link_to "Sign up now!", signup_path %></p>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@
<div class="row"> <div class="row">
<div class="col-md-6 col-md-offset-3"> <div class="col-md-6 col-md-offset-3">
<%= turbo_frame_tag "signup_form" do %>
<%= form_with(model: @user, local: true) do |f| %> <%= form_with(model: @user, local: true) do |f| %>
<%= render 'shared/error_messages' %> <%= render 'shared/error_messages' %>
@ -20,5 +21,6 @@
<%= f.submit "Create my account", class: "btn, btn-primary" %> <%= f.submit "Create my account", class: "btn, btn-primary" %>
<% end %> <% end %>
<% end %>
</div> </div>
</div> </div>

View File

@ -14,7 +14,7 @@ Rails.application.routes.draw do
get '/signup', to: 'users#new' get '/signup', to: 'users#new'
get '/login', to: 'sessions#new' get '/login', to: 'sessions#new'
post 'login', to: 'sessions#create' post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy' delete '/logout', to: 'sessions#destroy'
resources :users resources :users

View File

@ -44,7 +44,7 @@ class UsersLoginTest < ActionDispatch::IntegrationTest
assert_not is_logged_in? assert_not is_logged_in?
assert_redirected_to root_url assert_redirected_to root_url
follow_redirect! follow_redirect!
assert_select "a[href=?]", login_path # assert_select "a[href=?]", login_path
assert_select "a[href=?]", logout_path, count: 0 assert_select "a[href=?]", logout_path, count: 0
assert_select "a[href=?]", user_path(@user), count: 0 assert_select "a[href=?]", user_path(@user), count: 0
end end