I am trying to create an event within a method of a separate controller (from the model I am creating).
def checkin
#create a new event with todays date
new_event = Event.new()
new_event[:date] = todays_date(current_merchant)
@event = current_merchant.events.create(new_event)
end
I get this error:
undefined method
stringify_keys'`
I have a method that generates todays date, but I don't believe that is the issue since I've tested it with an actual date and still get the same stringify error.
Date is an attribute, here is my schema:
create_table "events", force: true do |t|
t.string "name"
t.date "date"
t.integer "age"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "merchant_id"
t.string "photo"
end
I've tried using new_event.date
but get the same error.
The error gets highlighted in terminal on the following line:
@event = current_merchant.events.create(new_event)
The error that shows up in console is the following:
(0.3ms) BEGIN
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 4495ms
NoMethodError (undefined method `stringify_keys' for #<Event:0x007f7f8f2a26f8>):
app/controllers/merchants_controller.rb:25:in `checkin'
Rendered /Users/steclaudinodaffara/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.7ms)
Rendered /Users/steclaudinodaffara/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /Users/steclaudinodaffara/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered /Users/steclaudinodaffara/.rvm/gems/ruby-2.1.1/gems/actionpack-4.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (14.5ms)