Skip to content
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

Fix 'Pages' list on admin #3327

Closed

Commits on Nov 14, 2017

  1. Fix 'Pages' list on admin

    Issue:
    'Pages' list doesn't work in the admin area.
    
    Error description:
    ActionView::Template::Error (comparison of Fixnum with nil failed):
    25:
    26: <% if Refinery::I18n.frontend_locales.many? %>
    27:   <span class='locales'>
    28:     <% page.translations.sort_by{ |t| Refinery::I18n.frontend_locales.index(t.locale)}.each do |translation| %>
    29:       <% if translation.title.present? %>
    30:         <%= link_to refinery.admin_edit_page_path(page.nested_url, switch_locale: translation.locale),
    31:                     class: 'locale', title: translation.locale.upcase do %>
    app/views/refinery/admin/pages/_page.html.erb:28
    
    How to reproduce:
    1. Add 'a' and 'b' locales to frontend_locales.
    config.frontend_locales = [:a, :b]
    2. Create 'b' translation for a page.
    3. Remove 'b' locale from frontend_locales.
    config.frontend_locales = [:a]
    4. Load 'Pages' listing page in admin.
    
    Cause:
    Refinery tries to sort page translations based on their locale's position in frontend_locales array.
    Once locale is removed, sort tries to compare nil as position index with a Fixnum.
    takacszoltansandor committed Nov 14, 2017
    Configuration menu
    Copy the full SHA
    d9f580f View commit details
    Browse the repository at this point in the history