haml:_notification.html.haml
.notification
- flash.each do |key, value|
= content_tag :div, value, class: key
--When using devise, a flash object is automatically created and multiple messages are saved with key :, value: values. --By using each statement, these are taken out one by one and displayed by using "key" as "class name for CSS" and "value" as "message body to be displayed". --Display on screen
haml:application.html.haml
%body
= render 'layouts/notifications'
= yield
↑ Since the view file of each page is displayed in the yield
part, write = render'layouts / notifications'
on it to display the flash message at the top of the page. ↓
stylesheets/modules/flash.scss
.notification {
.notice {
background-color: $light_blue;
color: $white;
text-align: center;
}
.alert {
background-color: $alert_orange;
color: $white;
text-align: center;
}
}
//Separate notification and alert messages
application.scss
@import "reset";
@import "config/colors";
@import "modules/flash";
//flash.Reflect scss
//reset.Described under the css file name defined as css
--Create new files named "devise.ja.yml" and "ja.yml" in the "config / locales" folder
config/application.rb
module ChatSpace
class Application < Rails::Application
#~abridgement~
config.i18n.default_locale = :ja
end
end
//config/application.Add one sentence to rb and set Japanese
Recommended Posts