我有错误 ActionView :: Template :: Error:没有Ransack :: Search对象已提供给search_form_for! 我尝试使用源代码
it "displays all the users" do
assign(:users, [
FactoryBot.create(:user, name: "slicer"),
FactoryBot.create(:user, name: "dicer")
])
render
expect(rendered).to match /slicer/
expect(rendered).to match /dicer/
结束
我在控制器的方法索引中使用了rasack
def index
@q = User.ransack params[:q]
@users = @q.result.newest._page params[:page]
respond_to do |format|
format.html
format.xls{send_data @users.to_xsl}
end
结束 这就是我的观点
<div class="input-group search_inline">
<%= search_form_for @q do |f| %>
<%= f.label :user %>
<%= f.search_field :user_cont, placeholder: t(".search") %>
<%= f.submit t(".search"), name: nil, class: "btn btn-primary
btn_search" %>
<% end %>
</div>
请帮助我!