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

Not working on available_locales has no 'en' configuration #28

Open
ash-r1 opened this issue Feb 23, 2022 · 3 comments
Open

Not working on available_locales has no 'en' configuration #28

ash-r1 opened this issue Feb 23, 2022 · 3 comments

Comments

@ash-r1
Copy link

ash-r1 commented Feb 23, 2022

I'm using this gem with a non-English product.
I realized this gem crashes without :en on I18n.available_locales like that:

I18n.available_locales = [:ja] # or something excepts :en

It crashes here:

%td= l(object.created_at, format: :long, default: l(object.created_at, format: :long, locale: :en))

error message is:

Showing /home/ash/.anyenv/envs/rbenv/versions/3.0.3/lib/ruby/gems/3.0.0/gems/rails_admin_history_rollback-1.0.3/app/views/rails_admin/main/history.html.haml where line #41 raised:

:en is not a valid locale
@ciscolive
Copy link

``
d15dd7ff-0e64-478f-a3b3-6dc4401fb928
not working with rails_admin 3.0 ,can not see rollback button

@marcelino056
Copy link

Its also happening on english, checking a bit deeper looks like the new version contain a view for history witch is the one rendered instead of the version on the history_rollback gem.

app/views/rails_admin/main/history.html.erb

<% params = request.params.except(:action, :controller, :model_name) %>
<% query = params[:query] %>
<% filter = params[:filter] %>
<% sort = params[:sort] %>
<% sort_reverse = params[:sort_reverse] %>
<% path_method = params[:id] ? "history_show_path" : "history_index_path" %>
<%= form_tag("", method: "get", class: "search form-inline") do %>
  <div class="card mb-3 p-3 bg-light">
    <div class="row">
      <div class="col-sm-6">
        <div class="input-group">
          <input class="form-control" name="query" placeholder="<%= t("admin.misc.filter") %>" type="search" value="<%= query %>" />
          <button class="btn btn-primary" data-disable-with="<%= '<i class="fas fa-sync"></i> ' + t('admin.misc.refresh') %>" type="submit">
            <i class="fas fa-sync"></i>
            <%= t("admin.misc.refresh") %>
          </button>
        </div>
      </div>
    </div>
  </div>
<% end %>
<table class="table table-condensed table-striped table-hover" id="history">
  <thead>
    <tr>
      <% columns = [] %>
      <% columns << { property_name: "created_at", css_class: "created_at",link_text: t('admin.table_headers.created_at') } %>
      <% columns << { property_name: "username",   css_class: "username",  link_text: t('admin.table_headers.username')   } %>
      <% columns << { property_name: "item",       css_class: "item",      link_text: t('admin.table_headers.item')       } if @general %>
      <% columns << { property_name: "message",    css_class: "message",   link_text: t('admin.table_headers.message')    } %>
      <% columns.each do |column| %>
        <% property_name = column[:property_name] %>
        <% selected = (sort == property_name) %>
        <% sort_direction = (sort_reverse ? "headerSortUp" : "headerSortDown" if selected) %>
        <% sort_location = send(path_method, params.except("sort_reverse").merge(model_name: @abstract_model.to_param, sort: property_name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {})) %>
        <th class="header <%= column[:css_class] %> <%= sort_direction if selected %>" data-href="<%= sort_location %>">
          <%= column[:link_text] %>
        </th>
      <% end %>
    </tr>
  </thead>
  <tbody class="table-group-divider">
    <% @history.each_with_index do |object, index| %>
      <tr>
        <% unless object.created_at.nil? %>
          <td>
            <%= l(object.created_at, format: :long, default: l(object.created_at, format: :long)) %>
          </td>
        <% end %>
        <td>
          <%= object.username %>
        </td>
        <% if @general %>
          <% if o = @abstract_model.get(object.item) %>
            <% label = o.send(@abstract_model.config.object_label_method) %>
            <% if show_action = action(:show, @abstract_model, o) %>
              <td>
                <%= link_to(label, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: o.id)) %>
              </td>
            <% else %>
              <td>
                <%= label %>
              </td>
            <% end %>
          <% else %>
            <td>
              <%= "#{@abstract_model.config.label} ##{object.item}" %>
            </td>
          <% end %>
        <% end %>
        <td>
          <%= object.message.in?(['delete', 'new']) ? t("admin.actions.#{object.message}.done").capitalize : object.message %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<% unless params[:all] || [email protected]_to?(:current_page) %>
  <%= paginate(@history, theme: 'ra-twitter-bootstrap') %>
  <%= link_to(t("admin.misc.show_all"), send(path_method, params.merge(all: true)), class: "show-all btn btn-light") unless (tc = @history.total_count) <= @history.size || tc > 100 %>
<% end %>

@mikhaillopandia
Copy link

Hi marcelino056
Have you found what was the issue?
I'm facing the same problem on a new rails project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants