where to put partials for rails_admin views

Viewed 2666

I am trying to use a partial to customize my edit view in rails_admin. In config/initializers/rails_admin.rb I have:

RailsAdmin.config do |config|

  config.model 'Album' do
    edit do
      field :promotion do
        partial :hello_world
      end
    end
  end

end

I have also tried the other syntax that can be found on the rails_admin wiki:

RailsAdmin.config do |config|

  config.model 'Album' do
    edit do
      field :promotion do
         def render
            bindings[:view].render :partial => carrierwave.to_s, :locals => {:field => self, :form => bindings[:form]}
         end
      end
    end
  end

end

I am locating my partial at app/views/rails_admin/main/_hello_world.html.erb with the content:

<h1>Hello World!</h1>

After restarting my server nothing shows up in the edit view except for an empty 'promotion' field.

Rails_admin had a github issue for this. The discussion seemed inconclusive and the issue was closed before anyone confirmed that the solution worked for them. The issue can be viewed here:

https://github.com/sferik/rails_admin/issues/787

The moderator creates a spec for the issue and then closes it. The spec can be viewed at the very bottom of this file:

https://github.com/sferik/rails_admin/blob/59da00303ca2162089b7dd7653a2f19494fb74b4/spec/unit/config/fields/base_spec.rb

My concern with the spec is that it does not test where rails_admin looks for the partial. According to the rails_admin wiki partials should be location in app/views/rails_admin/main/

Please help me understand what I'm doing wrong or, at least, please assure me that rails_admin does not still have an issue here. I'm using Rails 4 and Ruby 2.0.0

2 Answers
Related