Skip to content

Commit

Permalink
a few final minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
eacaps committed Aug 1, 2016
1 parent 566d62f commit 5637162
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions app/helpers/react_on_rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ def initialize_redux_stores
# rubocop:disable Metrics/AbcSize
def rails_context(server_side:)
@rails_context ||= begin
result = { inMailer: controller.present? && controller.is_a?(ActionMailer::Base) }
result = {
inMailer: controller.present? && controller.is_a?(ActionMailer::Base),
# Locale settings
i18nLocale: I18n.locale,
i18nDefaultLocale: I18n.default_locale
}
if request.present?
# Using Addressable instead of standard URI to better deal with
# non-ASCII characters (see https://github.com/shakacode/react_on_rails/pull/405)
Expand All @@ -360,10 +365,6 @@ def rails_context(server_side:)
port: uri.port,
pathname: uri.path, # /posts
search: uri.query, # id=30&limit=5

# Locale settings
i18nLocale: I18n.locale,
i18nDefaultLocale: I18n.default_locale,
httpAcceptLanguage: request.env["HTTP_ACCEPT_LANGUAGE"]
)
end
Expand Down
8 changes: 4 additions & 4 deletions spec/dummy/config/initializers/react_on_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module RenderingExtension
# Return a Hash that contains custom values from the view context that will get passed to
# all calls to react_component and redux_store for rendering
def self.custom_context(view_context)
result = {}
unless view_context.controller.is_a?(ActionMailer::Base)
result = {
if view_context.controller.is_a?(ActionMailer::Base)
{}
else
{
somethingUseful: view_context.session[:something_useful]
}
end
result
end
end

Expand Down

0 comments on commit 5637162

Please sign in to comment.