I am still new to rails/ruby etc and I am trying to build an app that will allow to select work days for a restaurant. The idea is to add an option to select on which days the restaurant works using check_box.
I want to save work days number in the database using their number (0 for sunday etc).
In my app/views/restaurants/_form.html.slim:
Date::ABBR_DAYNAMES.each do |day|
= day
= check_box :work_days_array, {miltiple: true}, Date::ABBR_DAYNAMES.index(day), false
The db/schema.rb contains:
t.integer "work_days_array", array: true
It returns the following error:
undefined method `delete' for 0:Fixnum
From what I understand the error is caused by Date::ABBR_DAYNAMES.index(day)
The intended result should be an array of only checked weekdays like
work_days_array: [1, 3, 4]
Can anybody please explain to me the error?
Aucun commentaire:
Enregistrer un commentaire