質問編集履歴
2
再編集
title
CHANGED
File without changes
|
body
CHANGED
@@ -72,6 +72,53 @@
|
|
72
72
|
|
73
73
|
end
|
74
74
|
```
|
75
|
+
```Ruby
|
76
|
+
# == Schema Information
|
77
|
+
#
|
78
|
+
# Table name: shops
|
79
|
+
#
|
80
|
+
# id :integer not null, primary key
|
81
|
+
# email :string default(""), not null
|
82
|
+
# encrypted_password :string default(""), not null
|
83
|
+
# number_of_post :integer default(1), not null
|
84
|
+
# reset_password_token :string
|
85
|
+
# reset_password_sent_at :datetime
|
86
|
+
# remember_created_at :datetime
|
87
|
+
# sign_in_count :integer default(0), not null
|
88
|
+
# current_sign_in_at :datetime
|
89
|
+
# last_sign_in_at :datetime
|
90
|
+
# current_sign_in_ip :inet
|
91
|
+
# last_sign_in_ip :inet
|
92
|
+
# created_at :datetime not null
|
93
|
+
# updated_at :datetime not null
|
94
|
+
#
|
95
|
+
# Indexes
|
96
|
+
#
|
97
|
+
# index_salons_on_email (email) UNIQUE
|
98
|
+
# index_salons_on_reset_password_token (reset_password_token) UNIQUE
|
99
|
+
#
|
100
|
+
```
|
101
|
+
```Ruby
|
102
|
+
# == Schema Information
|
103
|
+
#
|
104
|
+
# Table name: shop_basics
|
105
|
+
#
|
106
|
+
# id :integer not null, primary key
|
107
|
+
# shop_name :string default(""), not null
|
108
|
+
# shop_hp_address :string
|
109
|
+
# representive_name :string
|
110
|
+
# contact_personnel_name :string
|
111
|
+
# farm_name :string
|
112
|
+
# postal_code :string
|
113
|
+
# farm_prefectures :string
|
114
|
+
# farm_address :string
|
115
|
+
# use_email :string default(""), not null
|
116
|
+
# phone_number :string
|
117
|
+
# contact_personnel_phone :string
|
118
|
+
# created_at :datetime not null
|
119
|
+
# updated_at :datetime not null
|
120
|
+
#
|
121
|
+
```
|
75
122
|
他のページのViewではshop_basicの値もうまく取得できているので、以下のfavoriteアクションが悪さをしているのかなと思ってはいるのですが…
|
76
123
|
favorite_postsとsalonがリレーションを持てていないみたいです。
|
77
124
|
|
1
情報の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -56,4 +56,27 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
どうすればこのリレーションでshopのデータを取得できるでしょうか。
|
59
|
-
ご教示よろしくお願いいたします。
|
59
|
+
ご教示よろしくお願いいたします。
|
60
|
+
|
61
|
+
---
|
62
|
+
情報追加
|
63
|
+
ShopBasicのモデルになります。
|
64
|
+
|
65
|
+
```Ruby
|
66
|
+
class SalonBasic < ActiveRecord::Base
|
67
|
+
belongs_to :shop, autosave: true, foreign_key: 'id'
|
68
|
+
|
69
|
+
before_create do
|
70
|
+
self.id = shop.id
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
```
|
75
|
+
他のページのViewではshop_basicの値もうまく取得できているので、以下のfavoriteアクションが悪さをしているのかなと思ってはいるのですが…
|
76
|
+
favorite_postsとsalonがリレーションを持てていないみたいです。
|
77
|
+
|
78
|
+
```Ruby
|
79
|
+
def favorite
|
80
|
+
@feed_posts = current_applicant.favorite_posts
|
81
|
+
end
|
82
|
+
```
|