我有一个rails 3应用程序与ActiveAdmin宝石.我的目标是使自定义控件在自定义视图中呈现,从而保持布局.
pages.rb:
ActiveAdmin.register_page 'Pages' do content only: :index do render 'index' end content only: :edit do render partial: 'edit' end controller do def index @search = Page.includes(:translations).where("page_translations.locale='fr'").Metasearch(params[:search]) @pages = @search.page params[:page] end def edit @page = Page.find params[:id] end end end
例如我的index.html.erb文件:
<h1>Pages</h1> <%= form_for @search,:url => admin_pages_path,:html => {:method => :get,:class => "form-inline" } do |f| %> <%= f.text_field :translations_name_contains,:class => "search-query input-medium focused" %> <%= f.submit("Search",:class => "btn btn-primary") %> <% end %> <table> <thead> <tr> <th><%= sort_link @search,:translations_name,"Titre" %></th> <th><%= sort_link @search,:permalink,"Permalien" %></th> <th>Actions</th> </tr> </thead> <tbody> <% @pages.each do |page| %> <tr> <td><%= page.name %></td> <td><%= page.permalink %></td> <td><%= link_to("Update",edit_admin_page_path(page)) %></td> </tr> <% end %> </tbody> </table>
有没有办法保持ActiveAdmin布局?