Home > front end >  Rails Best In Place date initial date format
Rails Best In Place date initial date format

Time:06-03

I'm really new to Rails and I'm using v6.1.4. In my application I'm using I18n localization. At other places for view-only label dates(not using BIP) I use

<%=l @client.active_date.to_date %> 

and it works. However, in Best-In-Place there is a different syntax.

<span ><%= best_in_place task, :due_date, :as => :date, class: 'hyperlink'  %></span>

This causes the dates to be displayed in the yyyy-mm-dd format throughout. I want the dates to be formatted according to the locales currently in my application. I'm using the JQuery datepicker, but it is activated after I click on the date, and the format is changed to what I have set on the jquery setDefaults option.

How do I tackle this?

CodePudding user response:

I think this post addresses your question.

You could add a display_as: :formatted_date to your method call and define that formatted_date method in your model. From there you should be able to format dates as needed.

  • Related