Created
November 16, 2014 07:34
-
-
Save onemanstartup/c6248bc88a0ab9fe502b to your computer and use it in GitHub Desktop.
flashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flash_success(message = nil, opts = {}) | |
if message | |
flash[:success] = message | |
else | |
flash[:success] = translate '.flash.success_html'.freeze, view_assigns.symbolize_keys.merge(opts).merge(default: :"flash.default.success") | |
end | |
end | |
def flash_error(message = nil, opts = {}) | |
if message | |
flash[:error] = message | |
else | |
flash[:error] = t '.flash.error_html'.freeze, view_assigns.symbolize_keys.merge(opts).merge(default: :"flash.default.error") | |
end | |
end | |
def flash_custom(type, message = nil, opts = {}) | |
if message | |
flash[:type] = message | |
else | |
flash[:type] = t ".flash.#{type}_html".freeze, view_assigns.symbolize_keys.merge(opts).merge(default: :"flash.default.#{type}") | |
end | |
end | |
ru: | |
flash: | |
default: | |
success: 'Действие выполнено успешно' | |
error: 'Действие было выполнено с ошибкой' | |
feedbacks: | |
new: | |
flash: | |
success_html: "hello %{email}" | |
flash_error 'hello', email: current_user.email | |
flash_error 'hello' | |
flash_success | |
flash_custom :notice | |
flash_custom :notice, 'hello' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment