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

Missing partial rails_admin/main/_form_globalize_tabs in ruby 3 #43

Open
raelgc opened this issue Oct 28, 2022 · 5 comments
Open

Missing partial rails_admin/main/_form_globalize_tabs in ruby 3 #43

raelgc opened this issue Oct 28, 2022 · 5 comments

Comments

@raelgc
Copy link

raelgc commented Oct 28, 2022

While using:

  • ruby 3.1.2
  • rails 6.1.7
  • rails_admin 3.0.0
  • rails_admin_globalize_field 1.2.0

I'm getting the following error while trying to edit any model:

ActionView::MissingTemplate in RailsAdmin::Main#edit

Showing /home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin-3.0.0/app/views/rails_admin/main/edit.html.erb where line #2 raised:

Missing partial rails_admin/main/_form_globalize_tabs with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby]}. Searched in:
  * "/home/rael/Projects/www/foobar/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/delayed-web-0.4.9/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin_globalize_field-1.2.0/app/views"
  * "/home/rael/.rvm/gems/ruby-3.1.2@foobar-set/gems/rails_admin-3.0.0/app/views"
@raelgc raelgc changed the title Missing partial rails_admin/main/_form_globalize_tabs in rails 3 Missing partial rails_admin/main/_form_globalize_tabs in ruby 3 Oct 28, 2022
@Sankalp-Dwivedi
Copy link

Hi, @raelgc did you got any luck with this?
Things are also not working for rails 7. @scarfacedeb

@raelgc
Copy link
Author

raelgc commented Jan 3, 2023

No luck, same issue with rails 7 too. Basically I've got ride of this gem and, as in our project we have only 1 admin, we've are leaving now with the raw i18n entries.

@newfylox
Copy link

newfylox commented Feb 1, 2023

Since haml format is no longer supported in new rails_admin 3, we need to override the template, using erb format for example.

Right now I have the form showing BUT the issue that I have right now is that it doesn't update my translation fields when saving the form.

Do you have an idea of what I need to change to make my nested form updates the fields?

<%# create a file app/views/rails_admin/main/_form_globalize_tabs.html.erb and put the code below %>

<div class="controls">
  <ul class="nav nav-tabs" role="tablist" style="margin-top:5px">
    <% field.tabs.each do |tab| %>
      <li class="nav-item" role="presentation">
        <button class="nav-link<%= (" active" if tab.active?) %><%= " text-danger" unless tab.valid? %>" id="<%= tab.label %>-tab" data-bs-toggle="tab" data-bs-target="#<%= tab.label %>" type="button" role="tab" aria-controls="<%= tab.label %>" aria-selected="true"><%= tab.label %></button>
      </li>
    <% end %>
  </ul>
</div>
<div class="tab-content">
  <% field.tabs.each do |tab| %>
    <%= form.fields_for field.name, tab.translation, wrapper: false do |f| %>
      <div class="tab-pane fade<%= (' show active' if tab.active?) %> fields" id="<%= tab.label %>" role="tabpanel" aria-labelledby="<%= tab.label %>-tab">
        <%= f.generate(action: :nested, model_config: field.associated_model_config, nested_in: field) %>
      </div>
    <% end %>
  <% end %>
</div>

@Sankalp-Dwivedi
Copy link

Yes, did the same but fails to add new or edit, says translation missing even when they are filled.

what I think is some code is failing in /lib/rails_admin_globalize_field/tab.rb on initialize method
image

or in lib/rails_admin_globalize_field/globalize_tabs.rb on tabs method
image

as while debugging I found that the translations records are not initializing even though the params have the value of the translation in the correct nested format.
No feasible solution found yet still debugging it :(

@newfylox
Copy link

newfylox commented Feb 1, 2023

I don't have this issue. All those methods are being triggered when I put breakpoints and it's all good. Probably you missed something in configuration file? My problem is that even with those methods working good and my template showing correctly, the PUT form doesn't push my fields to params and it doesn't save.

here's my configuration

models/category.rb

class Category < ApplicationRecord
  # ...
  translates :eligible, :name
  accepts_nested_attributes_for :translations, allow_destroy: true
  # ...
end

config/initializers/rails_admin.rb

RailsAdmin.config do |config|
  # ...
  config.included_models = %w(Category Category::Translation)

  config.model 'Category' do
    configure :translations, :globalize_tabs
  end
  # ...
end

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

3 participants