[Ruby] Ruby on Rails 5 Quick Learning Practice Guide 5.2 compatible Chapter 3

3 minute read

Capter3 Let’s make a task management application

Create a simple “task management application” with CRUD from scratch without using scaffold.

environment

  • Ruby 2.5.1

  • Ruby on Rails 5.2.1

  • PostgreSQL 10.5

Enable to output Rails error messages etc. in Japanese Download the translated file (raw file) from Rails-i18n repository on Github as config/locales/ja.yml.

wget https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml --output-file=config/locales/ja.yml

When you check config/locales/ja.yml, the following logs are listed.

–2020-06-26 14:40:30– https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml Connecting to 192.168.24.1:8080…Connected. Request sent by Proxy, waiting for response…200 OK Length: 5117 (5.0K) [text/plain] Saving to `ja.yml’

0K …. 100% 10.3M=0s

2020-06-26 14:40:31 (10.3 MB/s)-Save to `ja.yml’ completed [5117/5117]

To the web browser as a solution https://raw.githubusercontent.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml Stick. Paste the contents of the displayed text below into ja.yml and save.


ja: activerecord: errors: messages: record_invalid:’Validation failed: %{errors}’ restrict_dependent_destroy: has_one: “Cannot be deleted because %{record} exists” has_many: “Can’t delete because %{record} exists” date: abbr_day_names: - Day - Moon -Fire - water - wood - Money -Sat abbr_month_names: - - January - February -March -April - May - June - July -August - September - October - November - December day_names: -Sunday -Monday -Tuesday -Wednesday -Thursday -Friday - Saturday formats: default: “%Y/%m/%d” long: “%Y year %m month %d day (%a)” short: “%m/%d” month_names: - - January - February -March -April - May - June - July -August - September - October - November - December order: -:year -:month -:day datetime: distance_in_words: about_x_hours: one: about 1 hour other: about %{count} hours about_x_months: one: about 1 month other: about %{count} months about_x_years: one: about 1 year other: about %{count} years almost_x_years: one: less than a year other: “%{count} or less” half_a_minute: around 30 seconds less_than_x_seconds: one: within 1 second other: “Less than %{count} seconds” less_than_x_minutes: one: within 1 minute other: “Less than %{count} minutes” over_x_years: one: over a year other: “more than %{count} years” x_seconds: one: 1 second other: “%{count} seconds” x_minutes: one: 1 minute other: “%{count} minutes” x_days: one: 1 day other: “%{count} days” x_months: one: 1 month other: “%{count} months” x_years: one: 1 year other: “%{count} years” prompts: second: second minute: minute hour: hour day: day month: month year: year errors: format: “%{attribute}%{message}” messages: accepted: Please accept Please enter blank: The confirmation: and %{attribute} inputs do not match Please enter empty: equal_to: should be %{count} even: should be an even number exclusion: is reserved greater_than: must be greater than %{count} greater_than_or_equal_to: must be greater than %{count} inclusion: is not in the list invalid: is an invalid value less_than: must be less than %{count} less_than_or_equal_to: must be less than %{count} model_invalid:’Validation failed: %{errors}’ Please enter a numerical value for not_a_number: Please enter an integer for not_an_integer: odd: should be odd other_than: must be a value other than %{count} do not enter present: Please enter required: taken: already exists Please enter too_long: within %{count} characters too_short: Please enter at least %{count} characters wrong_length: Please enter %{count} characters template: body: Please check the following items header: one: “Error occurred in %{model}” other: “%{model} encountered %{count} errors” helpers: select: prompt: Please select submit: create: register submit: save update: Update number: currency: format: delimiter: “,” format: “%n%u” precision: 0 separator: “.” significant: false strip_insignificant_zeros: false unit: Yen format: delimiter: “,” precision: 3 separator: “.” significant: false strip_insignificant_zeros: false human: decimal_units: format: “%n %u” units: billion: billion million: million quadrillion: 1000 trillion thousand: thousand trillion: trillion unit:’’ format: delimiter:’’ precision: 3 significant: true strip_insignificant_zeros: true storage_units: format: “%n%u” units: byte: byte eb: EB gb: GB kb: KB mb: MB pb: PB tb: TB percentage: format: delimiter:’’ format: “%n%” precision: format: delimiter:’’ support: array: last_word_connector: “,” two_words_connector: “,” words_connector: “,” time: am: am formats: default: “%Y year %m month %d day (%a) %H hour %M minute %S second %z”long: “%Y/%m/%d %H:%M” short: “%m/%d %H:%M” pm: afternoon

Now you are ready to create the application.