質問編集履歴

2

再編集

2015/07/31 13:32

投稿

jusco
jusco

スコア80

test CHANGED
File without changes
test CHANGED
@@ -146,6 +146,100 @@
146
146
 
147
147
  ```
148
148
 
149
+ ```Ruby
150
+
151
+ # == Schema Information
152
+
153
+ #
154
+
155
+ # Table name: shops
156
+
157
+ #
158
+
159
+ # id :integer not null, primary key
160
+
161
+ # email :string default(""), not null
162
+
163
+ # encrypted_password :string default(""), not null
164
+
165
+ # number_of_post :integer default(1), not null
166
+
167
+ # reset_password_token :string
168
+
169
+ # reset_password_sent_at :datetime
170
+
171
+ # remember_created_at :datetime
172
+
173
+ # sign_in_count :integer default(0), not null
174
+
175
+ # current_sign_in_at :datetime
176
+
177
+ # last_sign_in_at :datetime
178
+
179
+ # current_sign_in_ip :inet
180
+
181
+ # last_sign_in_ip :inet
182
+
183
+ # created_at :datetime not null
184
+
185
+ # updated_at :datetime not null
186
+
187
+ #
188
+
189
+ # Indexes
190
+
191
+ #
192
+
193
+ # index_salons_on_email (email) UNIQUE
194
+
195
+ # index_salons_on_reset_password_token (reset_password_token) UNIQUE
196
+
197
+ #
198
+
199
+ ```
200
+
201
+ ```Ruby
202
+
203
+ # == Schema Information
204
+
205
+ #
206
+
207
+ # Table name: shop_basics
208
+
209
+ #
210
+
211
+ # id :integer not null, primary key
212
+
213
+ # shop_name :string default(""), not null
214
+
215
+ # shop_hp_address :string
216
+
217
+ # representive_name :string
218
+
219
+ # contact_personnel_name :string
220
+
221
+ # farm_name :string
222
+
223
+ # postal_code :string
224
+
225
+ # farm_prefectures :string
226
+
227
+ # farm_address :string
228
+
229
+ # use_email :string default(""), not null
230
+
231
+ # phone_number :string
232
+
233
+ # contact_personnel_phone :string
234
+
235
+ # created_at :datetime not null
236
+
237
+ # updated_at :datetime not null
238
+
239
+ #
240
+
241
+ ```
242
+
149
243
  他のページのViewではshop_basicの値もうまく取得できているので、以下のfavoriteアクションが悪さをしているのかなと思ってはいるのですが…
150
244
 
151
245
  favorite_postsとsalonがリレーションを持てていないみたいです。

1

情報の追加

2015/07/31 13:32

投稿

jusco
jusco

スコア80

test CHANGED
File without changes
test CHANGED
@@ -115,3 +115,49 @@
115
115
  どうすればこのリレーションでshopのデータを取得できるでしょうか。
116
116
 
117
117
  ご教示よろしくお願いいたします。
118
+
119
+
120
+
121
+ ---
122
+
123
+ 情報追加
124
+
125
+ ShopBasicのモデルになります。
126
+
127
+
128
+
129
+ ```Ruby
130
+
131
+ class SalonBasic < ActiveRecord::Base
132
+
133
+ belongs_to :shop, autosave: true, foreign_key: 'id'
134
+
135
+
136
+
137
+ before_create do
138
+
139
+ self.id = shop.id
140
+
141
+ end
142
+
143
+
144
+
145
+ end
146
+
147
+ ```
148
+
149
+ 他のページのViewではshop_basicの値もうまく取得できているので、以下のfavoriteアクションが悪さをしているのかなと思ってはいるのですが…
150
+
151
+ favorite_postsとsalonがリレーションを持てていないみたいです。
152
+
153
+
154
+
155
+ ```Ruby
156
+
157
+ def favorite
158
+
159
+ @feed_posts = current_applicant.favorite_posts
160
+
161
+ end
162
+
163
+ ```