I have a model with start_date and end_date and a helper:
def period
"#{start_date} - #{end_date}"
If you want the dates to appear as localised strings you must do it
here. Formatting them as appropriate as you build the string. If I
understand the question correctly.
I defined my date formats in /config/locales/de.yml but I don't know
how to format my dates in my model. In view I can do <%=l
@schedule.start_date %>.
Can you tell me how I can do that with #{start_date}? The format I
need is dd.mm.yyy
I defined my date formats in /config/locales/de.yml but I don't know
how to format my dates in my model. In view I can do <%=l
@schedule.start_date %>.
Can you tell me how I can do that with #{start_date}? The format I
need is dd.mm.yyy
Have you tried #{l start_date}
The #{ } syntax in a double quoted string just says drop into ruby and
work out the expression between the braces.
Alternatively if you always want the same format you can use
#{start_date.strftime(some parameters to format it the way you want)}
I was hoping there was a way to use "l" in some way in my model. With
strftime it works.
Possibly l is only available in views. In which case you would have
to put the period method that uses "#{l @start-date} - #{l end-date}}"
in the view helper.