Skip to content

Instantly share code, notes, and snippets.

View DriesS's full-sized avatar

Dries Steenhouwer DriesS

View GitHub Profile
{
:pr08 =>
{:pays=>nil, :ville=>nil, :num=>nil, :lg_adr1=>nil, :lg_adr2=>nil, :lg_adr3=>nil, :cp=>nil, :lg_adr4=>nil},
:pr04 =>
{:pays=>nil, :ville=>nil, :num=>nil, :lg_adr1=>nil, :lg_adr2=>nil, :lg_adr3=>nil, :cp=>nil, :lg_adr4=>nil},
:pr09 =>
{:pays=>nil, :ville=>nil, :num=>nil, :lg_adr1=>nil, :lg_adr2=>nil, :lg_adr3=>nil, :cp=>nil, :lg_adr4=>nil},
:pr05 =>
{:pays=>nil, :ville=>nil, :num=>nil, :lg_adr1=>nil, :lg_adr2=>nil, :lg_adr3=>nil, :cp=>nil, :lg_adr4=>nil},
:pr10 =>
@DriesS
DriesS / gist:1222092
Created September 16, 2011 13:14
double select
SELECT `campaigns`.*, distinct campaigns.* FROM `campaigns` INNER JOIN
@DriesS
DriesS / gist:1228664
Created September 20, 2011 08:44
Problem activerecord searchlogic
search = Product
search = search.where(:product_type => "jeans")
search = search.where(:brand => "levis")
@products = search.all
@DriesS
DriesS / gist:1228665
Created September 20, 2011 08:46
Second query
search = Product
search = search.where(:product_type => "jeans")
@products = search.all
@DriesS
DriesS / gist:1322715
Created October 28, 2011 16:38
Routes in rails 2
RAILS 2
=============
map.resources :profile
profile_index GET /profile(.:format) {:action=>"index", :controller=>"profile"}
new_profile GET /profile/new(.:format) {:action=>"new", :controller=>"profile"}
GET /profile/:id/edit(.:format) {:action=>"edit", :controller=>"profile"}
profile POST /profile(.:format) {:action=>"create", :controller=>"profiles"}
new_profile GET /profile/new(.:format) {:action=>"new", :controller=>"profiles"}
GET /profile/edit(.:format) {:action=>"edit", :controller=>"profiles"}
GET /profile(.:format) {:action=>"show", :controller=>"profiles"}
PUT /profile(.:format) {:action=>"update", :controller=>"profiles"}
DELETE /profile(.:format)
@DriesS
DriesS / error.log
Created November 15, 2011 14:26
Problem rails 3
Association named 'inventory_items' was not found; perhaps you misspelled it?
preload_associations(results, [:pictures, :brand, :product_type, :available_inventory_items, :active_sale])
@brand = Brand.find_by_url_name!(params[:brand]) if params[:brand].present?
search = Product.where(:brand, @brand)
@DriesS
DriesS / Controller.rb
Created November 18, 2011 09:40
Problem with where active record
class ApplicationController < ActionController::Base
def get_brands(limit = nil)
@brands = cache("#{sub_menu_cache_key}:brand_list") do
@brands = Brand.joins(:products => [:sales]).merge(Sale.active).merge(Product.with_stock).to_sql
end
end
end
#ActiveRecord::ConfigurationError: Association named 'inventory_items' was not found; perhaps you misspelled it?