質問編集履歴
1
補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -82,6 +82,102 @@
|
|
82
82
|
|
83
83
|
```
|
84
84
|
|
85
|
+
app/models/offer.rb
|
86
|
+
|
87
|
+
```rails
|
88
|
+
|
89
|
+
class Offer < ApplicationRecord
|
90
|
+
|
91
|
+
has_many :entries
|
92
|
+
|
93
|
+
has_many :recruits
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
validates :belongings, :description, :hourly_wage, :meeting_point, :offer_name, :order_date, :ordering_staff,
|
98
|
+
|
99
|
+
:program_title, :recruitment_date, :staff, :travel_costs, :status, presence: true
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
validates :hourly_wage, :travel_costs, numericality: true
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
# status: "private" | "public" | "end"
|
108
|
+
|
109
|
+
validates :status, inclusion: {in: %w(private publish end)}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
scope :active, -> { where(is_deleted: 0) }
|
114
|
+
|
115
|
+
# 募集期間でソート
|
116
|
+
|
117
|
+
scope :order_by_recruitment_date, -> { order(recruitment_date: :asc) }
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
def pre_status
|
122
|
+
|
123
|
+
self.status.to_sym
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
factories/offers.rb
|
132
|
+
|
133
|
+
```rails
|
134
|
+
|
135
|
+
FactoryBot.define do
|
136
|
+
|
137
|
+
factory :offer do
|
138
|
+
|
139
|
+
offer_name "offer_name"
|
140
|
+
|
141
|
+
program_title "program_title"
|
142
|
+
|
143
|
+
staff "staff"
|
144
|
+
|
145
|
+
description "description"
|
146
|
+
|
147
|
+
order_date "2018/11/11 11:11"
|
148
|
+
|
149
|
+
ordering_staff "ordering_staff"
|
150
|
+
|
151
|
+
meeting_point "meeting_point"
|
152
|
+
|
153
|
+
belongings "belongings"
|
154
|
+
|
155
|
+
hourly_wage 10
|
156
|
+
|
157
|
+
travel_costs 20
|
158
|
+
|
159
|
+
passed_message "passed_message"
|
160
|
+
|
161
|
+
failure_message "failure_message"
|
162
|
+
|
163
|
+
remarks "remarks"
|
164
|
+
|
165
|
+
internal_remarks "internal_remarks"
|
166
|
+
|
167
|
+
recruitment_date "2018/11/11 00:00"
|
168
|
+
|
169
|
+
status "end"
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
174
|
+
|
175
|
+
```
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
85
181
|
|
86
182
|
|
87
183
|
リレーションにどこか不備があるのでしょうか?
|