Skip to content

Instantly share code, notes, and snippets.

View markoh's full-sized avatar

Marko Hriberšek markoh

View GitHub Profile
(Refinery.i18n_enabled? ? Refinery::I18n.frontend_locales : [:en]).each do |lang|
I18n.locale = lang
if defined?(Refinery::User)
Refinery::User.all.each do |user|
if user.plugins.where(:name => 'refinerycms-cars').blank?
user.plugins.create(:name => 'refinerycms-cars',
:position => (user.plugins.maximum(:position) || -1) +1)
end
end
def self.search_filter(name,manufacture_id,product_type_id)
f_name = "'%#{name}%'"
f_manufacture_id = manufacture_id
f_manufacture_id = f_manufacture_id.join(', ') unless manufacture_id.nil?
f_product_type_id = "'#{product_type_id}'"
conditions = ["'1'='1'"]
conditions << "name LIKE #{f_name}" unless name.empty?
conditions << "manufacture_id IN (#{f_manufacture_id})"# unless manufacture_id.nil?