Created
November 15, 2011 14:26
-
-
Save DriesS/1367198 to your computer and use it in GitHub Desktop.
Problem rails 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Association named 'inventory_items' was not found; perhaps you misspelled it? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Product < ActiveRecord::Base | |
| has_many :inventory_items, :include => :size, :order => 'sizes.position ASC' , :conditions => {:deleted => false} | |
| scope :available_for_gallery, lambda {|*options| | |
| options = options.flatten.first | |
| conditions = sanitize_sql_for_conditions(["inventory_items.in_stock - inventory_items.processing > 0 AND inventory_items.deleted = ?", false]) | |
| joins = :inventory_items | |
| if (options && options[:size].present? rescue false) | |
| conditions += " AND " + sanitize_sql_for_conditions( {"size_categories.name" => options[:size].split(/-/) } ) | |
| joins = {joins => {:size => :size_categories} } | |
| end | |
| joins(joins).where(conditions) | |
| } | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment