私は次のように私のrailsモデル内で現在の日付を取得しようとしています:
Photo.rbの内部
Paperclip.interpolates :prefix do |attachment, style|
:today_date => Date.today.to_s
"#{:today_date}/#{attachment.instance.image_file_name}"
end
クライアントからサーバーに写真を送信すると、エラーが発生し、サーバーに次のコンソール出力が表示されます。これは、「日付」機能に問題があることを示しています
サーバーコンソール:
Started POST "/photos.json" for 127.0.0.1 at 2013-02-20 13:47:35 -0800
13:47:35 web.1 |
13:47:35 web.1 | SyntaxError
(/Users/AM/Documents/RailsWS/test/app/models/photo.rb:22: syntax
error, unexpected tASSOC, expecting keyword_end
13:47:35 web.1 | :today_date => Date.today.to_s
13:47:35 web.1 | ^):
13:47:35 web.1 | app/controllers/photos_controller.rb:1:in `<top (required)>'
私は何が間違っているのですか?現在の日付をこの変数に取り込むにはどうすればよいですか?
ありがとう