-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1547] Add and use Current.locale #1623
Conversation
<ul> | ||
<li class="nav-link"><%= link_to t('header.locale_articles'), language_path(@site_locale.canonical) %></li> | ||
<li class="nav-link"><%= link_to t('header.locale_articles'), language_path(Current.locale.name) %></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is the source of the test failures, but canonical
== slug
<li class="nav-link"><%= link_to t('header.locale_articles'), language_path(Current.locale.name) %></li> | |
<li class="nav-link"><%= link_to t('header.locale_articles'), language_path(Current.locale.slug) %></li> |
def set_current_locale | ||
Current.locale = ::Locale.find_by abbreviation: I18n.locale | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is why the tests are failing.
You are making it so that the routing logic now depends on the locale database tables to exist an be populated
this will be nil
in the specs because there are no locales, and that will make line 36 fail.
return if Current.locale.english? |
you can get the specs passing by putting before { create(:locale, :en) }
at the top of the failing specs, but this brings up a question for me
should middleware routing be tied to the state of the DB? and does making a database call outside of application code introduce any risks (security or otherwise)
I am not familiar enough with rack to really know, but if it's fine then adding the before
in failing specs should do the trick
Closes #1547
Like #1621
Use
CurrentAttributes
for the current locale, which can be set from: