I am trying to return the current users created gifts in the controller method below before I search using the Ransack gem, can anyone help with suggesting the correct approach to this?
def mygifts
#Gift = current_user.gifts << Trying to assign constant with current users gifts before ransack search
@q = Gift.search(params[:q])
@gifts = @q.result.order(sort_column + " " + sort_direction).paginate(:per_page => 6, :page => params[:page])
end
I've not got experience with the ransack
gem, but my gut tells me your trying to overwrite the Gift
constant is going to cause big problems (name conflict etc)
Have you tried using:
@q = current_user.gifts.search(params[:q])