今現在、dateの表示をyear/month/dayからday/month/yearに変えようと試みてはいるのですが、day/month/yearに一向に変わらない状態になっています。もしわかる方がいらしたら、教えていただきたいです。
config/application.rb
config/application.rb
1require File.expand_path('../boot', __FILE__) 2 3require 'rails/all' 4 5# Require the gems listed in Gemfile, including any gems 6# you've limited to :test, :development, or :production. 7Bundler.require(*Rails.groups) 8 9module Surfing 10 class Application < Rails::Application 11 # Settings in config/environments/* take precedence over those specified here. 12 # Application configuration should go into files in config/initializers 13 # -- all .rb files in that directory are automatically loaded. 14 15 # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 16 # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 17 # config.time_zone = 'Central Time (US & Canada)' 18 19 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 20 # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 21 config.i18n.default_locale = :en 22 23 # Do not swallow errors in after_commit/after_rollback callbacks. 24 config.active_record.raise_in_transactional_callbacks = true 25 end 26end 27
config/locals/en.yml
# Files in the config/locales directory are used for internationalization # and are automatically loaded by Rails. If you want to use locales other # than English, add the necessary files in this directory. # # To use the locales, use `I18n.t`: # # I18n.t 'hello' # # In views, this is aliased to just `t`: # # <%= t('hello') %> # # To use a different locale, set it with `I18n.locale`: # #I18n.locale = :en #I18n.l(datetimes.to_date, formats: :long) # # This would use the information in config/locales/es.yml. # # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" en: date: formats: default: ! '%d/%m/%y' long: ! '%d/%m/%y' short: ! '%d/%m'
view/index.html.erb
view
1 <p class="date" type="text" name="datetimes" class="form-control" id='datetimepicker4'>Date: <%= @plan.datetimes %></p>
view/new.html.erb
view
1<%= date_field_tag :datetimes, (params[:datetimes] || 2 Time.zone.today.strftime("%d/%m/%Y")) %>
回答1件
あなたの回答
tips
プレビュー