Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't create method if name has spaces and isn't plural #28

Closed
krainboltgreene opened this issue Apr 13, 2012 · 4 comments
Closed

Doesn't create method if name has spaces and isn't plural #28

krainboltgreene opened this issue Apr 13, 2012 · 4 comments

Comments

@krainboltgreene
Copy link

Somewhere it should mention this.

1.9.1 :045 > Spree::RelationType.create name: "Something Something", applies_to: "Spree::Product"
  SQL (0.9ms)  INSERT INTO "spree_relation_types" ("applies_to", "created_at", "description", "name", "updated_at") VALUES (?, ?, ?, ?, ?)  [["applies_to", "Spree::Product"], ["created_at", Fri, 13 Apr 2012 17:40:59 UTC +00:00], ["description", nil], ["name", "Something Something"], ["updated_at", Fri, 13 Apr 2012 17:40:59 UTC +00:00]]
 => #<Spree::RelationType id: 7, name: "Something Something", description: nil, applies_to: "Spree::Product", created_at: "2012-04-13 17:40:59", updated_at: "2012-04-13 17:40:59"> 
1.9.1 :046 > Spree::RelationType.create name: "Something Somethings", applies_to: "Spree::Product"
  SQL (0.5ms)  INSERT INTO "spree_relation_types" ("applies_to", "created_at", "description", "name", "updated_at") VALUES (?, ?, ?, ?, ?)  [["applies_to", "Spree::Product"], ["created_at", Fri, 13 Apr 2012 17:41:22 UTC +00:00], ["description", nil], ["name", "Something Somethings"], ["updated_at", Fri, 13 Apr 2012 17:41:22 UTC +00:00]]
 => #<Spree::RelationType id: 8, name: "Something Somethings", description: nil, applies_to: "Spree::Product", created_at: "2012-04-13 17:41:22", updated_at: "2012-04-13 17:41:22"> 
1.9.1 :047 > Spree::Product.last
  Spree::Product Load (0.3ms)  SELECT "spree_products".* FROM "spree_products" ORDER BY "spree_products"."id" DESC LIMIT 1
 => #<Spree::Product id: 101, name: "Product #100 - 2084", description: "Voluptas deserunt asperiores est. Ea nisi atque aut...", available_on: "2011-04-13 15:10:40", deleted_at: nil, permalink: "product-number-100-2084", meta_description: nil, meta_keywords: nil, tax_category_id: 1, shipping_category_id: 1, created_at: "2012-04-13 15:10:43", updated_at: "2012-04-13 15:10:43", count_on_hand: 0> 
1.9.1 :048 > Spree::Product.last.something_something
  Spree::Product Load (0.2ms)  SELECT "spree_products".* FROM "spree_products" ORDER BY "spree_products"."id" DESC LIMIT 1
  Spree::RelationType Load (0.4ms)  SELECT "spree_relation_types".* FROM "spree_relation_types" WHERE "spree_relation_types"."applies_to" = 'Spree::Product' ORDER BY name
NoMethodError: undefined method `something_something' for #<Spree::Product:0x007f87e0df7810>
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/gems/activemodel-3.1.4/lib/active_model/attribute_methods.rb:385:in `method_missing'
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/gems/activerecord-3.1.4/lib/active_record/attribute_methods.rb:60:in `method_missing'
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/bundler/gems/spree_related_products-dcac3c3aff2b/app/models/spree/product_decorator.rb:48:in `method_missing'
    from (irb):48
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/gems/railties-3.1.4/lib/rails/commands/console.rb:45:in `start'
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/gems/railties-3.1.4/lib/rails/commands/console.rb:8:in `start'
    from /Users/krainboltgreene/Code/mignon-faget/vendor/ruby/1.9.1/gems/railties-3.1.4/lib/rails/commands.rb:40:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
1.9.1 :049 > Spree::Product.last.something_somethings
  Spree::Product Load (0.3ms)  SELECT "spree_products".* FROM "spree_products" ORDER BY "spree_products"."id" DESC LIMIT 1
  Spree::RelationType Load (0.4ms)  SELECT "spree_relation_types".* FROM "spree_relation_types" WHERE "spree_relation_types"."applies_to" = 'Spree::Product' ORDER BY name
  Spree::Relation Load (0.2ms)  SELECT related_to_id FROM "spree_relations" WHERE "spree_relations"."relatable_id" = 101 AND "spree_relations"."relatable_type" = 'Spree::Product' AND "spree_relations"."relation_type_id" = 7
  Spree::Product Load (0.3ms)  SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" IN (NULL) AND "spree_products"."deleted_at" IS NULL AND (spree_products.available_on IS NOT NULL) AND (spree_products.available_on <= '2012-04-13 17:41:35.980064')
 => []
1.9.1 :050 > 1.9.1 :RelationType.create name: "Something Otherthings", applies_to: "Spree::Product"
  SQL (0.6ms)  INSERT INTO "spree_relation_types" ("applies_to", "created_at", "description", "name", "updated_at") VALUES (?, ?, ?, ?, ?)  [["applies_to", "Spree::Product"], ["created_at", Fri, 13 Apr 2012 17:44:05 UTC +00:00], ["description", nil], ["name", "Something Otherthings"], ["updated_at", Fri, 13 Apr 2012 17:44:05 UTC +00:00]]
 => #<Spree::RelationType id: 9, name: "Something Otherthings", description: nil, applies_to: "Spree::Product", created_at: "2012-04-13 17:44:05", updated_at: "2012-04-13 17:44:05"> 
1.9.1 :051 > Spree::Product.last.something_otherthings
  Spree::Product Load (0.3ms)  SELECT "spree_products".* FROM "spree_products" ORDER BY "spree_products"."id" DESC LIMIT 1
  Spree::RelationType Load (0.4ms)  SELECT "spree_relation_types".* FROM "spree_relation_types" WHERE "spree_relation_types"."applies_to" = 'Spree::Product' ORDER BY name
  Spree::Relation Load (0.2ms)  SELECT related_to_id FROM "spree_relations" WHERE "spree_relations"."relatable_id" = 101 AND "spree_relations"."relatable_type" = 'Spree::Product' AND "spree_relations"."relation_type_id" = 9
  Spree::Product Load (0.2ms)  SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" IN (NULL) AND "spree_products"."deleted_at" IS NULL AND (spree_products.available_on IS NOT NULL) AND (spree_products.available_on <= '2012-04-13 17:44:10.139542')
 => [] 
@radar
Copy link
Contributor

radar commented Apr 16, 2012

Where would you mention this?

@krainboltgreene
Copy link
Author

The view itself (I'll make a PR probably around 2PM CST) and in the README (I can also make a PR for this).

But really, I don't know if this extention is even needed. Related Items handles what amounts to user set relationships, specifically a many to many relationship. Isn't that what a Product Group is?

@radar
Copy link
Contributor

radar commented Apr 16, 2012

Alright, great. Looking forward to that.

I don't know for certain. You know that product groups have been extracted out into their own extension now, yes?

@radar radar closed this as completed Apr 16, 2012
@krainboltgreene
Copy link
Author

Nope, although I guess I'm not surprised as Product Groups are just zero level Taxonomies with extra behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants