Sha256: 415062cebd3dd8b9439bc943c352d789149593daa0da3177ea0c2cff8c6fdc8c
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
module Spree module Admin ProductsController.class_eval do def selected_for_question @question = load_question @products = @question.products respond_with(:admin, @products) end def available_for_question @question = load_question @products = params[:q].blank? ? [] : Spree::Product.where('lower(name) LIKE ?', "%#{params[:q].mb_chars.downcase}%") @products.delete_if { |product| @question.products.include?(product) } respond_with(:admin, @products) end def select_for_question @question = load_question @product = Product.find_by_permalink(params[:id]) @question.products << @product @question.save @products = @question.products respond_with(:admin, @products) end def remove_for_question @question = load_question @product = Product.find_by_permalink(params[:id]) @question.products.delete(@product) @question.save @products = @question.products respond_with(:admin, @product) end private def load_question Question.find_by_slug(params[:question_id]) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems