Skip to content

Commit 8779e5f

Browse files
committed
Remove hidden input tag
1 parent e290e3b commit 8779e5f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

app/views/notes/show.html.erb

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
<% if @current_user %>
1010
<% like = Like.find_by(user_id: @current_user.id, note_id: @note.id) %>
1111
<% if like %>
12-
<%= form_tag "/likes/destroy" do %>
13-
<input type="hidden" name="note_id" value="<%= @note.id %>">
12+
<%= form_tag "/notes/#{@note.id}/destroy_like" do %>
1413
<span class="fa fa-heart unlike"></span>
1514
<input type="submit" value="お気に入り済み(<%= @note.likes.count %>" class="unlike">
1615
<% end %>
1716
<% else %>
18-
<%= form_tag '/likes/create' do %>
19-
<input type="hidden" name="note_id" value="<%= @note.id %>">
17+
<%= form_tag "/notes/#{@note.id}/create_like" do %>
2018
<span class="fa fa-heart like"></span>
2119
<input type="submit" value="お気に入り(<%= @note.likes.count %>" class="like">
2220
<% end %>

config/routes.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Rails.application.routes.draw do
22
get 'users/:user_id/likes' => 'likes#index'
3-
post 'likes/create' => 'likes#create'
4-
post 'likes/destroy' => 'likes#destroy'
3+
post '/notes/:note_id/create_like' => 'likes#create'
4+
post '/notes/:note_id/destroy_like' => 'likes#destroy'
55

66
get 'signup' => 'users#new'
77
get 'login' => 'users#login_form'

0 commit comments

Comments
 (0)