2013-05-02 125 views
0

我試圖實現RefineryCMS搜索引擎,我遵循的指導https://github.com/refinery/refinerycms-search#search-plugin-for-refinery-cms的步驟,但是因爲我的自定義擴展實現這一點,我可能失去了一些東西:實施RefineryCMS搜索引擎

application.rb中:

config.to_prepare do 
    Refinery.searchable_models = [Refinery::Doctors::Doctor] 
end 

型號:

module Refinery 
    module Doctors 
    class Doctor < Refinery::Core::BaseModel 
     self.table_name = 'refinery_doctors' 

     attr_accessible :prefix, :full_name, :bio, :specialty, :branch, :schedule, :location, :position, :dr_img, :dr_img_id 

     acts_as_indexed :fields => [:prefix, :full_name, :bio, :specialty, :branch, :schedule, :location, :dr_img, :dr_img_id] 
     alias_attribute :title, :full_name 

     validates :prefix, :presence => true 
     belongs_to :dr_img, :class_name => '::Refinery::Image' 
     has_many :branches 
    end 
    end 
end 

控制器:

def show 

    # you can use meta fields from your model instead (e.g. browser_title) 
    # by swapping @page for @doctor in the line below: 
    present(@page) 
    end 

protected 

    def find_all_doctors 
    @doctors = Doctor.order('branch ASC').paginate(:page => params[:page], :per_page => 20) 

    end 

查看:

<div class="clearfix"> 
<div class="span3 dotted"> 
<% content_for :side_body do %> 
    <aside> 
    <h2>Otros Especialistas<%#= t('.other') %></h2> 

     <% @doctors.each do |doctor| %> 
     <% if @doctor.branch == doctor.branch && @doctor.full_name != doctor.full_name %> 
      <ul id="doctors"> 
      <li> 
       <%= link_to doctor.prefix + ' ' + doctor.full_name, refinery.doctors_doctor_path(doctor) %> 
      </li> 
      </ul> 

     <% end %> 
    <% end %> 
    </aside> 
<% end %> 

</div> 


<div class="clearfix"> 
<% content_for :body do %> 
    <section> 
     <div class="span3"> 
       <p><%= image_fu @doctor.dr_img, '250x250'%></p> 
     </div> 

     <div class="span4"> 
     <h1><%= @doctor.prefix + ' ' + @doctor.full_name %></h1> 
     <h2><%= @doctor.specialty %></h2> 
     <strong>Horario: </strong><%=raw @doctor.schedule %><br> 
     <strong>Consultorio: </strong><%=raw @doctor.location %> 
     <h3>Biografía:</h3> 
     <p> 
      <%=raw @doctor.bio %> 
     </p> 


     </div> 

    </section> 
<% end %> 


<%= render '/refinery/content_page' %> 
</div> 

錯誤:

https://gist.github.com/jmercedes/5503185

回答

1

@doctor沒有在你的代碼的任何地方定義。您需要將以下行添加到控制器中的#show動作中。

@doctor = Doctor.find(params[:id])