samedi 8 avril 2017

Ransack undefined method `empty?'

i'm trying to get a collection of feedbacks from the shop but

using ransack and search and comment_cont from feedbacks and the logs show:

ActionView::Template::Error (undefined method `empty?' for #<Feedback:0x007f189a8fb330>)

someone know why like this?

the route is:

resources :shops, only: [:new, :create, :edit, :update, :show] do

post '/:id/feedbacks', to: 'shops#feedbacks', as: :search_feedbacks post '/:id/products', to: 'shops#products', as: :search_products

on shops controller

def feedbacks

begin
  @shop = Shop.cached_find(params[:id])
rescue
  @shop = nil
end

unless @shop.nil?

  # @feedbacks = Feedback.by_participant(@vitrine.user, Feedback::FROM_BUYERS).paginate(:per_page => 22, :page => params[:page]).order('created_at DESC')
  @q = Feedback.by_participant(@vitrine.user, Feedback::FROM_BUYERS).ransack(params[:q])
  @feedbacks = @q.result(distinct: true).paginate(page: params[:page], per_page: 22)
  @average_rating_from_buyers = Feedback.average_rating(@vitrine.user, Feedback::FROM_BUYERS)



end

end

Aucun commentaire:

Enregistrer un commentaire