Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created January 7, 2012 02:52
Show Gist options
  • Save mgreenly/1573597 to your computer and use it in GitHub Desktop.
Save mgreenly/1573597 to your computer and use it in GitHub Desktop.
Date Time Parsing in Controllers #1
class ItemsController < ApplicationController
# unrelated code....
def create
@item = Item.new(params[:item])
@item.invented_at = DateTime.parse(params[:item][:invented_at])
if @item.save
redirect_to @item, :notice =>"The Item successfully created"
else
render :action => 'new'
end
end
# unrelated code....
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment