Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why rails_admin route only work in link_to and not in 'render'

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?

like image 430
Achaius Avatar asked Dec 19 '12 04:12

Achaius


1 Answers

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

like image 110
mccannf Avatar answered Oct 06 '22 12:10

mccannf