Closed desmondrawls closed 5 years ago
First solution should work.
Second should read:
render do
bindings[:view].render :partial => "rails_admin/main/_hello_world", :locals => {:field => self, :form => bindings[:form] }
end
I think, this issue should be reopened because it's not working in Rails 4 with Ruby 2.1.5 for me either.
as simple doesn't works:
RailsAdmin.config do |config|
config.model 'Model' do
show do
field :field_name do
partial :partial_name
end
end
end
with partial in app/views/rails_admin/main/_partial_name.html.haml
I guess if the partial doesn't exist should thrown a error what is not happens either.
@shingonoide According to https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/fields/base.rb#L112
The partial is never actually called for the show method.
The following works with rails 4.X and railsadmin (current release), hope this helps.
#ruby
show do
field :lat do
formatted_value do
bindings[:view].render :partial => "rails_admin/main/partial", :locals => {:field => self, :object => bindings[:object] }
end
end
end
This one NOT working with rails_admin-1.1.1
.
Seems to be fixed now
In my case formatted_value
not work. I used pretty_value
.
For example:
pretty_value do
bindings[:view].render partial: 'images_gallery', locals: {object: self}
end
rails_admin 1.2 ruby 2.3.0
latest everything: ping!
I was running into this issue as well.
# does not render partial
field :field_name do
partial 'partial_name'
end
# rendered partial but `form` was nil
pretty_value do
bindings[:view].render partial: 'images_gallery', locals: {object: self}
end
# working with `form` available
field :field_name do
pretty_value do
bindings[:view].render partial: partial.to_s, locals: {:field => self, :form => bindings[:form]}
end
end
rails_admin 2.0 rails 5 ruby 2.6
What's interesting is I use
field :field_name do
partial 'partial_name'
end
elsewhere in the codebase and it works fine
This issue is related to https://github.com/sferik/rails_admin/issues/787.
I am trying to use a partial to customize my edit view in rails_admin. In config/initializers/rails_admin.rb I have:
I have also tried the other syntax that can be found on the rails_admin wiki:
I am locating my partial at
app/views/rails_admin/main/_hello_world.html.erb
with the content:<h3>Hello World!</h3>
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