ruby on rails 3-如何在控制器中使用breadcrumbs_on_rrails



我尝试使用breadcrumbs_on_rrails,但每次都会出现错误:

syntax error, unexpected '(', expecting keyword_end add_breadcrumb "City", :doctors_city_sort_path(params[:city_id])

控制器内:

def sort_by_city
  @doctors = Doctor.where('city_id = ?', params[:city_id]).
    paginate(page: params[:page], :per_page =>10)
  add_breadcrumb "City", :doctors_city_sort_path(params[:city_id])
  render 'index'
end

在路线上。rb:

get '/doctors/city/:city_id', 
    to: 'doctors#sort_by_city', as: 'doctors_city_sort'

请帮助查找此任务的决策

您有一个冒号add_breadcrumb调用,请尝试以下操作:

def sort_by_city
  @doctors = Doctor.where('city_id = ?', params[:city_id]).
    paginate(page: params[:page], :per_page =>10)
  add_breadcrumb "City", doctors_city_sort_path(params[:city_id])
  render 'index'
end

我找到了决定!它看起来像:

 @city = City.find(params[:city_id])
 add_breadcrumb "#{@city.name}", "#{@city.id}"

相关内容

  • 没有找到相关文章

最新更新