我尝试使用breadcrumbs_on_rails,但每次都会收到错误:
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
在routes.rb中:
get '/doctors/city/:city_id',
to: 'doctors#sort_by_city', as: 'doctors_city_sort'
请帮助找到完成此任务的决定
答案 0 :(得分:0)
你有一个冒号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
答案 1 :(得分:0)
我找到了决定!它看起来像:
@city = City.find(params[:city_id])
add_breadcrumb "#{@city.name}", "#{@city.id}"