ruby - Rails database date issues -
my web app has 2 date_select parameters in. these should passed db searching later on. cannot function. see can see inspection parameters being passed date(3i) (2i) (1i). when create migrate file tables in fails if try add (3i) etc.. i've read in rails need manipulate in controller. i'm trying failing miserably. have thought basic attribute of db table. dates etc..
any pointers? code need see.
here parameters i'm passing...
"date(3i)"=>"19", "date(2i)"=>"4", "date(1i)"=>"2014", "date_of_change(3i)"=>"19", "date_of_change(2i)"=>"4", "date_of_change(1i)"=>"2014", class createposts < activerecord::migration def change create_table :posts |t| t.text :title t.text :requester t.text :requester_email t.text :customer t.text :contact t.text :customer_email t.text :customer_phone t.string :type_of_change t.timestamps
ok seem getting further here.... on rails console can see following date has been passed date_of_change still nil.
=> #<post id: 7, title: "", requester: "", requester_email: "", customer: "", contact: customer_email: "", customer_phone: "", type_of_change: "service change", created_at: "2014-04-19 21:32:53", updated_at: "2014-04-19 21:32:53", implementer: "", ticket: "", date: "2014-04-19", date_of_change: nil>
ok. have typo on permitted values. let me change that.
say model concert, migration file should this. it?
class createconcerts < activerecord::migration def change create_table :concerts |t| t.string :artist t.string :venue t.date :date #correct format date t.date :date_of_change t.timestamps end end end
so in case believe should
class createposts < activerecord::migration def change create_table :posts |t| t.text :title t.text :requester t.text :requester_email t.text :customer t.text :contact t.text :customer_email t.text :customer_phone t.string :type_of_change t.date :date t.date :date_of_change t.timestamps end end end
then run rake db:migrate
in post controller @ bottom should
def post_params params.require(:post).permit(:title, :requester, :requester_email, :customer, :contact, :customer_email, :customer_phone, :type_of_change, :date, :date_of_change) end
Comments
Post a Comment