There's not a lot of documentation as to how to use the display_with option in Best In place, but I'm trying to get Best_in_Place to display dates in condensed form, (mm/dd/yyyy). My db (sqlserver) has the dates stored in datetime format, and I use this command to display the field:
<%= best_in_place(@production, :budget_approval_internal, type: :date, :nil => "[Not set]") %>
When clicked the gem works as expected, putting up a calendar control to select the date, and then displaying it in short form. But when I press refresh I get a date that looks like:
2013-12-04 00:00:00 UTC
So I thought I could use the :display_with option to have use a helper that looks like this:
def format_date(my_date)
my_date.strftime('%m/%d/%Y')
end
I put this in the application_helper.rb module and then tried this:
<%= best_in_place(@production, :budget_approval_internal, type: :date, :display_with => :format_date, :nil => "[Not set]") %>
but I get an error in saying:
"can't find helper format_date. Any ideas?
Either you should include ApplicationHelper
in your controller or add the method to the appropriate helper file.
Edit : You need to open the ActionView::Base class and add your method
module ActionView
class Base
def format_date(rec)
rec.strftime('%m/%d/%Y')
end
end
end