Even for errors such as "You can understand by reading the error message!" </ B>, when you are a super beginner, you can rely on Google teacher for the time being. This article is an article on how to deal with an error written for such "copy and paste error messages for the time being" </ B> level Ruby on Rails super beginners.
Let's translate error messages into Japanese using I18n!
Reference: Japanese localization using I18n in Rails
Alright! I set the Japanese file downloaded from the web.
ja.yml
ja:
activerecord:
errors:
messages:
record_invalid: "Validation failed: %{errors}"
restrict_dependent_destroy:
has_one: "%{record}Cannot be deleted because it exists"
has_many: "%{record}Cannot be deleted because it exists"
that? Somehow there is an error ...
NoMethodError (undefined method `deep_symbolize_keys' for "String":String):
What do you mean?
The indentation in config> locales> ja.yml is incorrect and the i18n translation is not working.
The correct description is to lower the indent by two half-width spaces for each element. If you copy and paste, the indent may shift, so download the file with the command and place it under the config> locales folder.
#Download Japanese translation file template
wget https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/ja.yml -P config/locales/
ja:
activerecord:
errors:
messages:
record_invalid: "Validation failed: %{errors}"
restrict_dependent_destroy:
has_one: "%{record}Cannot be deleted because it exists"
has_many: "%{record}Cannot be deleted because it exists"
[NoMethodError (undefined method `deep_symbolize_keys' for" Hello ": String):](https://github.com/2016chubachi/tabitomo/wiki/NoMethodError- (undefined-method-% 60deep_symbolize_keys% 27-for-% 22% E3 % 81% 93% E3% 82% 93% E3% 81% AB% E3% 81% A1% E3% 81% AF% 22: String) :)
By default, Ruby on Rails displays error messages in English, so translate them into Japanese so that users can easily understand them.
How to make it compatible with Japanese with Rails
Japanese localization of Rails validation error message --Qiita
I am trying to read _comment.html.erb under comments from posts / index.html.erb.
Folder structure
app
- views
- posts
- index.html.erb
- comments
- _comment.html.erb
ruby:posts/index.heml.erb
<%= render partial: "comment" %>
that? An error…
Missing partial xxx/_yyy, application/_yyy with {:locale=>[:ja], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}.
The path of the partial view is specified incorrectly.
When rendering (reading) a partial view, specify the path with the folder name / view name. </ b>
ruby:posts/index.heml.erb
<%= render partial: "comments/comment" %>
I didn't specify the folder hierarchy, so I couldn't read it.
<Controller name>Controller#<Action name> is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: []
There is no view corresponding to the controller action
app> views> Create "action name.html.erb" under the folder of controller name
undefined local variable or method ` ' for #<xxxxx> (NameError)
What's wrong ...
ruby:posts/index.html.erb
<%= render partial: "comment" %>
Actually, double-byte spaces are included in the file.
Delete double-byte space. Allows you to discover double-byte spaces in the IDE settings.
What to do when ActionController :: RoutingError suddenly appears in the rails app after repair
Rails errors don't always depend on Ruby.
ExecJS::RuntimeError in Controller#Action
SyntaxError: missing / (unclosed regex)
What is unclosed regex ...?
The description of the app> assets> javascripts> .coffee file is incorrect. (The coding block is not closed, such as {}) Therefore, the part where the stylesheet is read in view (application.html.erb) is an error.
ruby:apps/view/layouts/application.html.erb
<%= stylesheet_link_tag 'application', media: 'all' %>
Review the description of the coffee file. Delete unnecessary parts.
Weird error "missing / (unclosed regex)"
How was it? It was too easy for Tsuyotsuyo engineers!
It's okay to google for the time being, but you can grow up from a super beginner even if you try to break down what the error message says once. We support your programming studies!