I have a ActiveModel in my model like below:
class PromotionCodesGenerator
include ActiveModel::Model
include ActiveModel::Validations
attr_accessor :no_of_codes,:start_date,:end_date
end
And the view like below
<%= simple_nested_form_for ([:admin, @promotion_codes_generator]) do |f| %>
<%= f.input :start_date, as: :date, default: Time.zone.now, wrapper_tag: :p %>
<%= f.input :end_date, as: :date, default: Time.zone.now + 1.month, wrapper_tag: :p %>
<% end %>
When the form is submitted the param looks like this
{"no_of_codes"=>"12", "start_date(1i)"=>"2016", "start_date(2i)"=>"12", "start_date(3i)"=>"15", "end_date(1i)"=>"2017", "end_date(2i)"=>"1", "end_date(3i)"=>"15"}
And of course this gives me error
undefined method `start_date(1i)='
when im trying to initiate the model in my controller.
@promotion_codes_generator = PromotionCodesGenerator.new(promotion_codes_generator_params)
So how should i handle the dates properly?