0
我的醫生有一個專業有專業的醫生顯示專業,職業模式也有專業領域,專業屬於醫生。請讓我知道如何根據地區和專業搜索醫生。搜索模型包含名稱,性別,區域,規格等字段。如果可以,請提供代碼。
這是我的搜索模式搜索相關搜索紅寶石軌道上
class Search < ActiveRecord::Base
#to help in searching methodolgy
belongs_to :patient
def search_docs
doctors = Doctor.all;
profession = Profession.all;
doctors = doctors.where(["name LIKE ?",name]) if name.present?
doctors = doctors.where(["sex LIKE ?",sex]) if sex.present?
doctors = profession.where(["spec LIKE ?",spec]) if spec.present?
doctors = doctors.where(["area LIKE ?",doctors.profession.area]) if area.present?
return doctors
end
end
while in my controller
def show
@search = Search.find(params[:id])
end
and in my show view
<% if @search.search_docs %>
<%[email protected]_docs.inspect%>
<% @search.search_docs.each do |c| %>
<div class="search-results">
<div class="row"><div class="col-md-1"> <img class="doc-profile-pic img img-rounded" alt="pciture"></div>
<div class="col-md-9 search-heading"><%=c.name%>
<div class="row"><div class="search-details"><% if c.profession%><%=c.profession.spec%><%else%><%="Nothing"%><%end%></div></div>
<div class="row"><div class="search-details1"><% if c.profession%><%=c.profession.fee%><%else%><%="Nothing"%><%end%></div></div>
<%=link_to "Profile", :controller => "doctors", :action => "profile", :id =>c.id , :patid => @search.patient_id %>
</div>
</div>
</div>
<%end%>
<% else %>
<p>Sorry, we have no physician that match your criteria. </p>
<p>We are adding new Doctors daily, come back soon</p>
<%end%>