簡単なCRUD処理を実装するアプリケーションを作成して、練習しています。
CRUDを実装した後、bootstrapを適用させ、レイアウトを整えてみよう、というところなのですが、submitボタンのサイズ変更と、日本語翻訳がうまくいきません。
このsubmitのupdate タスク
というボタンを、下の戻る
ボタンと同じサイズにしたいのと、日本語に直したいです。一緒に見てもらえませんか。
<%= f.submit class: 'btn btn-primary' %>
翻訳に関して自分で進めて見たこと
・en.ymlを複製し、それをja.ymlとして編集。
# Files in the config/locales directory are used for internationalization ja: time: formats: default: "%Y/%m/%d %H:%M:%S" am: 午前 pm: 午後 activerecord: models: task: タスク attributes: task: title: タイトル content: コンテンツ helpers: select: prompt: 選択してください submit: create: 登録する submit: 保存する update: 更新
・application.rbを編集
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module TaskApp class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.2 config.i18n.load_path += Dir[Rails.root.join('config','locales','*.{rb,yml}').to_s] config.i18n.default_locale = :ja # Settings in config/environments/* take precedence over those specified here. # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. end end
・edit.html.erb
注:登録ボタンを押すとupdateアクションに処理が飛ぶ <%= form_for @task do |f| %> <div> <%= f.text_field :title %> <%= f.label :title %> </div> <div> <%= f.text_field :content %> <%= f.label :content %> </div> <div> <%= f.submit class: 'btn btn-primary' %> </div> <%= link_to '戻る',tasks_path, class: "btn btn-light" %> <% end %>
submitのサイズ適用に関しては具体的な解決策が見つけられていません。
よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。