質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
###実現したいこと
|
2
2
|
|
3
3
|
複数選択したデータを一括でアクションに送りたいです。
|
4
|
-
|
5
|
-
shareアクションで一つのデータを、shareallで選択した複数のデータを、
|
6
4
|
|
7
5
|
|
8
6
|
|
1
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,19 +8,11 @@
|
|
8
8
|
|
9
9
|
```view
|
10
10
|
|
11
|
-
<%= form_tag "/
|
11
|
+
<%= form_tag "/houses/#{@house.id}/share" do %>
|
12
12
|
|
13
|
-
<% @
|
13
|
+
<% @rooms.each do |room| %>
|
14
14
|
|
15
|
-
<div class="post-photo">
|
16
|
-
|
17
|
-
<%= link_to( image_tag(post.image_name.url), "/books/#{@book.id}/share?post=#{post.id}", :method => :post) %>
|
18
|
-
|
19
|
-
<%= check_box_tag "posts[]", post.id %>
|
20
|
-
|
21
|
-
<div class="
|
15
|
+
<div class="checkbox"><%= check_box_tag "rooms[]", room.id %></div>
|
22
|
-
|
23
|
-
</div>
|
24
16
|
|
25
17
|
<% end %>
|
26
18
|
|
@@ -32,27 +24,13 @@
|
|
32
24
|
|
33
25
|
```Controller
|
34
26
|
|
35
|
-
def share
|
27
|
+
def share
|
36
28
|
|
37
|
-
@
|
29
|
+
@house = House.find_by(id: params[:id])
|
38
30
|
|
39
|
-
@
|
31
|
+
@rooms.find(params[:rooms])
|
40
32
|
|
41
|
-
@book.posts << @post
|
42
|
-
|
43
|
-
flash[:notice] = "追加しました"
|
44
|
-
|
45
|
-
redirect_to("/")
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def shareall
|
50
|
-
|
51
|
-
@book = Book.find_by(id: params[:id])
|
52
|
-
|
53
|
-
@posts.find(params[:posts])
|
54
|
-
|
55
|
-
@
|
33
|
+
@house.rooms << @rooms
|
56
34
|
|
57
35
|
flash[:notice] = "追加しました"
|
58
36
|
|