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

RuntimeError in Spree/admin/products#index in production mode #2697

Closed
harssh opened this issue Mar 14, 2013 · 8 comments
Closed

RuntimeError in Spree/admin/products#index in production mode #2697

harssh opened this issue Mar 14, 2013 · 8 comments

Comments

@harssh
Copy link

harssh commented Mar 14, 2013

spree version 1.3.x
ruby 1.9.3
rails 3.2.12

RuntimeError in Spree/admin/products#index

Showing /usr/lib/ruby/gems/1.9.1/gems/spree_core-1.3.2/app/views/spree/admin/products/index.html.erb where line #83 raised:

Spree::Product#master_images delegated to master.images, but master is nil: #<Spree::Product id: 1060543640, name: "SampleProductABC", description: nil, available_on: "2012-03-13 05:01:14", deleted_at: nil, permalink: "SampleProductABC", meta_description: nil, meta_keywords: nil, tax_category_id: nil, shipping_category_id: nil, count_on_hand: 5, created_at: "2012-03-13 05:01:14", updated_at: "2012-03-13 05:01:14", on_demand: false>
Extracted source (around line #83):

80: <% @collection.each do |product| %>
81: <tr <%= "style='color: red;'" if product.deleted? %> id="<%= spree_dom_id product %>" data-hook="admin_products_index_rows" class="<%= cycle('odd', 'even') %>">
82: <%= product.sku rescue '' %>
83: <%= mini_image(product) %>
84: <%= link_to product.try(:name), edit_admin_product_path(product) %>
85: <%= product.display_price rescue '' %>
86:

@GeekOnCoffee
Copy link
Contributor

master being nil means your product is mis-configured. How was your product created? Nothing within Spree should have allowed you to create a product without a master variant.

@radar
Copy link
Contributor

radar commented Mar 14, 2013

What Andrew said! :)

Please provide steps to reproduce this issue.

On 15/03/2013, at 4:51, Andrew Hooker notifications@github.com wrote:

master being nil means your product is mis-configured. How was your product created? Nothing within Spree should have allowed you to create a product without a master variant.


Reply to this email directly or view it on GitHub.

@harssh
Copy link
Author

harssh commented Mar 15, 2013

Well I am trying to create products from console by this
may be I am missing something or doing something wrong
Product is created in table but not shown in store and admin products page gives earlier error
*any suggestions !!!

uuid = SecureRandom.uuid

spree_products = "INSERT INTO spree_products (available_on, count_on_hand, created_at, name, permalink, updated_at) VALUES ('2012-03-13 05:01:14.585306',5,'2012-03-13 05:01:14.585306', 'SampleProductABC','#{uuid}','2012-03-13 05:01:14.585306')"

recordId = Spree::Product.connection.insert(spree_products)

spree_variants = "INSERT INTO spree_variants (cost_currency , cost_price, count_on_hand,is_master,on_demand, product_id, sku) VALUES ('USD',99.9,5,false,false, '#{recordId}', '#{uuid}' )"

result = ActiveRecord::Base.connection.execute(spree_variants)

Are there any commands or proper ways to create products from console .............

@GeekOnCoffee
Copy link
Contributor

Why are you doing it this way, and not using Spree::Product.create()?

You're missing the master variant, which is a definite Spree requirement.

Andrew Hooker
Support Engineer
Spree Commerce, Inc.

Register now for SpreeConf
May 20-21 in Washington, D.C.
http://spreeconf.com

On Mar 14, 2013, at 10:10 PM, Harssh notifications@github.com wrote:

Well I am trying to create products from console by this
may be I am missing something or doing something wrong
Product is created in table but not shown in store and admin products page gives earlier error
*any suggestions !!!

uuid = SecureRandom.uuid

spree_products = "INSERT INTO spree_products (available_on, count_on_hand, created_at, name, permalink, updated_at) VALUES ('2012-03-13 05:01:14.585306',5,'2012-03-13 05:01:14.585306', 'SampleProductABC','#{uuid}','2012-03-13 05:01:14.585306')"

recordId = Spree::Product.connection.insert(spree_products)

spree_variants = "INSERT INTO spree_variants (cost_currency , cost_price, count_on_hand,is_master,on_demand, product_id, sku) VALUES ('USD',99.9,5,false,false, '#{recordId}', '#{uuid}' )"

result = ActiveRecord::Base.connection.execute(spree_variants)


Reply to this email directly or view it on GitHub.

@harssh
Copy link
Author

harssh commented Mar 15, 2013

Ok I did this

p = Spree::Product.create(name: 'tryproduct', price: 12)
p.valid?
=> true
p.save

but it is not shown in store ........
Do I have to do something else for that ...........

@GeekOnCoffee
Copy link
Contributor

You'll want to set all the values you were setting in your SQL query… available_on is the big one you're missing I think… and count_on_hand depending on your inventory settings.

Andrew Hooker
Support Engineer
Spree Commerce, Inc.

Register now for SpreeConf
May 20-21 in Washington, D.C.
http://spreeconf.com

On Mar 14, 2013, at 10:10 PM, Harssh notifications@github.com wrote:

Well I am trying to create products from console by this
may be I am missing something or doing something wrong
Product is created in table but not shown in store and admin products page gives earlier error
*any suggestions !!!

uuid = SecureRandom.uuid

spree_products = "INSERT INTO spree_products (available_on, count_on_hand, created_at, name, permalink, updated_at) VALUES ('2012-03-13 05:01:14.585306',5,'2012-03-13 05:01:14.585306', 'SampleProductABC','#{uuid}','2012-03-13 05:01:14.585306')"

recordId = Spree::Product.connection.insert(spree_products)

spree_variants = "INSERT INTO spree_variants (cost_currency , cost_price, count_on_hand,is_master,on_demand, product_id, sku) VALUES ('USD',99.9,5,false,false, '#{recordId}', '#{uuid}' )"

result = ActiveRecord::Base.connection.execute(spree_variants)


Reply to this email directly or view it on GitHub.

@radar
Copy link
Contributor

radar commented Mar 15, 2013

I don't think there's anything left to do on this issue now. Closing.

@radar radar closed this as completed Mar 15, 2013
@harssh
Copy link
Author

harssh commented Mar 15, 2013

Yep done thanx @radar and @GeekOnCoffee

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

3 participants