0

我正在尝试实现RefineryCMS搜索引擎,我已按照指南https://github.com/refinery/refinerycms-search#search-plugin-for-refinery-cms上的步骤进行操作,但是因为我正在实施这个自定义扩展,我可能会遗漏一些东西:

应用程序.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

4

1 回答 1

1

@doctor没有在您的代码中的任何地方定义。您需要将以下行添加到控制器中的 #show 操作。

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

于 2013-12-15T08:00:53.263 回答