formから送信された値を受け取れてないことはわかりますが
何が間違ってるのかわかりません。
コントローラー
def new @schedule = Schedule.new end def create @schedule = Schedule.new(schedule_params) if @schedule.save #binding.pry flash.now[:success] = '登録が完了しました' redirct_to schedule_path else flash.now[:danger] = "登録に失敗しました" render :index end end private def schedule_params params.require(:schedule).permit(:selection,:start_time,:end_time,:break,:description) end
フォーム
ruby
1 <%= form_for @schedule url: schedules_path do |f| %> 2 <div class="form-group"> 3 <%= f.label :selection, "勤務区分", class: "text-white" %> 4<%= f.select :selection, [["-"],["出勤"], ["有給"], ["休み"]],{}, {class: 'form-control'}%> 5 </div> 6 <div class="form-group "> 7 <%= f.label :start_time,"開始:時間", class: "text-white " %> 8 <%= f.time_field :start_time,class: "form-control" %> 9 </div> 10 <div class="form-group"> 11 <%= f.label :end_time,"終了:時間", class: "text-white" %> 12 <%= f.time_field :end_time,class: "form-control" %> 13 </div> 14 <div class="form-group"> 15 <%= f.label :break,"休憩:時間", class: "text-white" %> 16 <%= f.time_field :break,class: "form-control" %> 17 </div> 18 <div class="form-group"> 19 <%= f.label :description,"作業日報", class: "text-white" %> 20 <%= f.text_area :description,class: "form-control" %> 21 </div> 22 23 <%= f.submit "登録する", class: "btn-block btn-white" %> 24 <% end %> 25 <%= link_to '勤務一覧へ', schedules_path,class: 'text-white' %>
マイグレーション
def change create_table :schedules do |t| t.string :selection t.time :start_time t.time :end_time t.time :break t.string :description t.timestamps end end end
よろしくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。