我一直在嘗試將Ransack搜索gem實現到我目前正在使用的項目中。我很確定我已經正確設置了它。我希望能夠搜索個人資料和已經把我的代碼在配置文件控制,像這樣:Ransack Ruby On Rails結果Wont Render
def index
@q = Profile.search(params[:q])
@profile = @q.result(distinct: true)
@profiles = Profile.all
end
和輪廓index.html.erb文件,像這樣:
<%= search_form_for @q do |f| %>
<div class="field">
<%= f.label :first_name_cont, "Name Contains" %>
<%= f.search_field :first_name_cont %>
</div>
<div class="actions"><%= f.submit "Search" %></div>
<% end %>
它確實在似乎最少似乎試圖正確地搜索數據庫,但不會在屏幕上顯示任何結果。這可能是顯而易見的,我只是沒有看到。任何幫助是極大的讚賞。
感謝古慕克,這並獲得成功。我對你給我的東西做了一些微小的修改。但它是非常重要的。非常感激。 –