我有一个Rails应用程序在这里运行,我正在构建一个RANSACK。
我已经安装了device,但实际上对用户索引页没有用处,相反,我有一个名为memberlistcontroller的控制器,其中包含目录方法,还有一个链接到它的目录页。这是我希望管理员用户查看成员目录的位置。(控制器见下文)
MemberListController.rb
class MemberListController < ApplicationController
before_action :authenticate_user!
def directory
@users = User.all
@q = User.ransack(params[:q])
@user = @q.result(distinct: true)
respond_to do |format|
format.html
format.xlsx
end
end
end
我将以下搜索表单内置到目录页:
<%= search_form_for @q do |f| %>
<%= f.label :f_name_or_l_name_or_email_or_business_name %>
<%= f.search_field :f_name_or_l_name_or_email_or_business_name %>
<%= f.submit %>
<% end %>
当我从目录页提交表单时(我希望在其中显示结果)。我得到以下错误:
UsersController#index is missing a template for this request format and variant. request.formats: ["text/html"] request.variant: [] NOTE! For XHR/Ajax or API requests, this action would normally respond with 204 No Content: an empty white screen. Since you're loading it in a web browser, we assume that you expected to actually render a template, not nothing, so we're showing an error to be extra-clear. If you expect 204 No Content, carry on. That's what you'll get from an XHR or API request. Give it a shot.
我不知道为什么我会通过目录控制器来管理所有的内容,而twats用户控制器或索引操作。
请不要确定我在这方面出了什么问题。有没有一种方法可以像ransack想要的那样把这个显示在用户控制器的外面?