0

In my movies database I have a release_date column, and it my form there is this <%= select_date Date.today, :prefix => :release_date %>. This works fine but how can I display the release_date in the movies show.html.erb

<%= @movie.release_date %> wont work, and so i dont know what else to use

Thanks

4

1 回答 1

1
<%= @movie.release_date.to_formatted_s(:short) %>

请参阅. _ DateTime#to_formatted_s这是典型的 Rails 方法。它接受其他参数,您可以定义自己的日期模板,这些都在文档中指定。

如果 Rails 不存在,您可以使用strftime#to_formatted_s它基本上是一个包装器。

于 2013-05-27T16:03:57.670 回答