5

I am trying to use rails_admin route in two ways

  1. = link_to "Users", rails_admin.index_path(:model_name => 'user')
  2. = render rails_admin.index_path(:model_name => 'user')

First one works fine, when click on the 'Users' link it navigate to the raisl_admin users list page with rails_admin layout. Where as second is not working it tries to fetch the layout from my app, so I am getting the error

Missing partial /rails_admin/user with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :haml, :slim]}

What is the difference between these two links? How to get the second one to work?

Achaius
  • 5,904
  • 21
  • 65
  • 122

1 Answers1

5

The render is looking for a partial file like /rails_admin/_user.html.erb to include within your current view. Note that using render in a view is different than using render in a controller. The filename being rendered is prepended with a _ and by default it uses the current view's layout.

http://guides.rubyonrails.org/layouts_and_rendering.html

mccannf
  • 16,619
  • 3
  • 51
  • 63
  • ok, How to get the second one to work? And also I am already in rails_admin page(i.e user group view page). My intension was to render the users list of that group. – Achaius Dec 19 '12 at 04:41
  • 1
    Not sure without seeing your code. You would have to return your @users in a list to this user group view, then create a `_user.html.erb` partial that is just a list of those users. But note you only need the partial if you are planning to re-use it in other views. Otherwise you might as well just incorporate the users list into the user group view. – mccannf Dec 19 '12 at 10:23