質問編集履歴

1

追記

2019/10/01 13:52

投稿

Tsuyoponpon
Tsuyoponpon

スコア33

test CHANGED
File without changes
test CHANGED
@@ -85,3 +85,89 @@
85
85
 
86
86
 
87
87
  説明が下手で伝わりにくいかもしれませんが、どうかご教授いただければと思います。
88
+
89
+
90
+
91
+ ### 追記
92
+
93
+ ```rb
94
+
95
+ #controllers/job_offer_controller.rb
96
+
97
+ def index
98
+
99
+ @company = Company.select("name") #会社名を取得
100
+
101
+ @job_offer = JobOffer.where(group: @company) #groupが会社名
102
+
103
+ end
104
+
105
+ ```
106
+
107
+ ```rb
108
+
109
+ #views/job_offer/index.html.erb
110
+
111
+
112
+
113
+ <p id="notice"><%= notice %></p>
114
+
115
+
116
+
117
+ <h1>加盟企業の求人一覧</h1>
118
+
119
+
120
+
121
+ <table>
122
+
123
+ <thead>
124
+
125
+ <tr>
126
+
127
+ <th>Title</th>
128
+
129
+ <th>Group</th>
130
+
131
+ <th>Content</th>
132
+
133
+ <th>Url</th>
134
+
135
+ <th colspan="3"></th>
136
+
137
+ </tr>
138
+
139
+ </thead>
140
+
141
+
142
+
143
+ <tbody>
144
+
145
+ <% @job_offer.each do |job_offer| %>
146
+
147
+ <tr>
148
+
149
+ <td><%= job_offer.title %></td>
150
+
151
+ <td><%= job_offer.group %></td>
152
+
153
+ <td><%= job_offer.content %></td>
154
+
155
+ <td><a href="<%= job_offer.url %>"><%= job_offer.url %></a></td>
156
+
157
+ <td><%= link_to 'Show', job_offer %></td>
158
+
159
+ <td><%= link_to 'Edit', edit_job_offer_path(job_offer) %></td>
160
+
161
+ <td><%= link_to 'Destroy', job_offer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
162
+
163
+ </tr>
164
+
165
+ <% end %>
166
+
167
+ </tbody>
168
+
169
+ </table> <br>
170
+
171
+ <%= link_to 'New Company', new_job_offer_path %>
172
+
173
+ ```