Skip to content

Instantly share code, notes, and snippets.

View deJaVisions's full-sized avatar

deJaVisions deJaVisions

View GitHub Profile
@deJaVisions
deJaVisions / gist:1911583
Created February 25, 2012 23:25
using rails 3.2 i'm having troubles doing a p = Proudct.first; p.materials
# models/material.rb
class Material < ActiveRecord::Base
has_many :products_materials
has_many :products, :through => :products_materials
validates :title, presence: true
end
# models/product.rb
class Product < ActiveRecord::Base
class Product < ActiveRecord::Base
has_many :materials, :through => :product_materials
has_many :products_material
end
class Material < ActiveRecord::Base
belongs_to :product, :through => :products_material
has_many :products_material
end
class Product < ActiveRecord::Base
has_many :materials, :through => :products_materials
end
class Material < ActiveRecord::Base
belongs_to :product, :through => :products_materials
end
class ProductsMaterials < ActiveRecord::Base
belongs_to :product
ActiveRecord::StatementInvalid in Spree::Admin::ProductsController#create
SQLite3::SQLException: no such column: spree_visual_codes.type_id: SELECT "spree_visual_codes".* FROM "spree_visual_codes" WHERE "spree_visual_codes"."code" IS NULL AND "spree_visual_codes"."type_id" IN (SELECT "spree_visual_code_types"."id" FROM "spree_visual_code_types" WHERE "spree_visual_code_types"."name" = 'Barcode')
Rails.root: /Users/phong/Sites/warehouse
<p data-hook="visual_code"><%= f.label :visual_codes, t(:singular, :scope => :visual_code) %>: <br />
<%= f.text_field :visual_code %>
</p>
phong:~/custom_gems/doktorj/spree_warehouse[(cd45c27...)]$ bundle exec rake test_app
Could not find gem 'rcov (>= 0) ruby' in any of the gem sources listed in your Gemfile.
phong:~/custom_gems/doktorj/spree_warehouse[(cd45c27...)]$ rake test_app
Generating dummy Rails application...
rake aborted!
Could not find gem 'rcov (>= 0) ruby' in any of the gem sources listed in your Gemfile.
phong:~/custom_gems/doktorj/spree_warehouse[master]$ bundle exec rake test_app
/Users/phong/custom_gems/doktorj/spree_warehouse/Gemfile:1:in `evaluate': undefined local variable or method `?' for #<Bundler::Dsl:0x0000010109be40> (NameError)
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `instance_eval'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler/dsl.rb:7:in `evaluate'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler/definition.rb:17:in `build'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler.rb:138:in `definition'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler.rb:126:in `load'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler.rb:110:in `setup'
from /Users/phong/.rvm/gems/ruby-1.9.3-p0@rails3.1.3/gems/bundler-1.0.21/lib/bundler/cli.rb:340:in `exec'
from /Users/phong/.rvm
@deJaVisions
deJaVisions / gist:1764086
Created February 8, 2012 01:36
trying to find spree product variants
Hi.
does anyone see any syntax issues with this? @variants just prints out an empty array, even tho I have 2 product variants, with their count_on_hand fields set. Hoping it's something simple.
product_ids = Spree::Product.all.map(&:id)
product_ids.each do |id|
product = Spree::Product.find_by_id(id); @variants = product.variants.all;
end
@variants.map(&:count_on_hand)
Thanx!
@deJaVisions
deJaVisions / gist:1757192
Created February 7, 2012 04:33
trying to use deface to append text to admin edit product sidebar from within spree_warehouse extension
Deface::Override.new(:virtual_path => "spree/layouts/admin/products",
:name => "spree_warehouse_add_visual_codes_to_edit_product_sidebar",
:insert_bottom => "[data-hook='admin_product_tabs']",
:text => "Visual Codes")
module Spree
class Role < ActiveRecord::Base
has_and_belongs_to_many :users, :join_table => 'spree_roles_users'
end
end