Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Jumping through hoops using Spree models to seed store data
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joseph Jackson  
View profile  
 More options Apr 30 2012, 5:59 pm
From: Joseph Jackson <joe.b.jackson...@gmail.com>
Date: Mon, 30 Apr 2012 17:59:46 -0400
Local: Mon, Apr 30 2012 5:59 pm
Subject: Re: [spree-user] Jumping through hoops using Spree models to seed store data

I'm not sure.  My clients opted to add all the products in by hand rather
than pay me to import their old data.  They are still working on it...

I do hear a lot about datashift on this group though.

On Mon, Apr 30, 2012 at 5:57 PM, bensullivan <bensulli...@bensullivan.net>wrote:

> Aaaaarrrrrrggggghhhhhh! (facepalm).

> That worked!

> Thanks so much.

> Is there a way to do this that requires less song and dance around the
> single line of code I'm interested in in the seeds file?

> Do folks tend to not use active_record models directly to import seed data
> and defer to straight yaml and tools like datashift?

> Cheers again

> Ben

> On Tuesday, 1 May 2012 07:49:12 UTC+10, Joe wrote:

>> Looks like it needs to be namespaced.

>> Spree::Product.create etc.

>> On Mon, Apr 30, 2012 at 5:45 PM, bensullivan <bensulli...@bensullivan.net
>> > wrote:

>>> Hi folks

>>> I am developing a new spree store for a client who only has about 15
>>> products currently so I just need to get them in without having to do it
>>> through the UI every time.

>>> I've been looking at the seeds.rb file in my new store generated by the
>>> spree install command.

>>> It seems like the place to do this kind of stuff and then plugging it in
>>> using the Rails rakes tasks.

>>> I figured it's safer using the Spree active_record models to import data
>>> as I only have maybe 15 or so products and I'll get all the data validation
>>> moving forward.  I have seen the spree_sample gem which seems to use yaml
>>> to get the demo store data in.  I was going to use that as the backup plan.

>>> So I'm trying to put a basic record creation line of code in the
>>> seeds.rb file:

>>> p = Product.create :name => "Moo", :price => 10.0, :description =>
>>> "meeeeep"

>>> I run "rake db:bootstrap" and I get this at the end of the output:

>>> rake aborted!
>>> uninitialized constant Product

>>> So then this triggers me to put in all the necessary requires - that's
>>> cool.  But then I find there's a few transitive dependencies and the model
>>> classes also need to be added to the load path for me to get to them:

>>> require 'rubygems'

>>> gem 'spree_core'
>>> directory = '/Users/bensullivan/.rvm/gems/**ruby-1.9.3-p125@geometry_**
>>> active_wear/gems/spree_core-1.**1.0'
>>> $LOAD_PATH.unshift(directory) unless $LOAD_PATH.include?(directory)

>>> require 'active_record'
>>> require 'active_support/core_ext/**module/attribute_accessors'
>>> require 'spree/core/delegate_belongs_**to'
>>> require 'app/models/spree/variant'
>>> require 'app/models/spree/product'

>>> p = Product.create :name => "Moo", :price => 10.0, :description =>
>>> "meeeeep"

>>> I get the same error when I retry the db:bootstrap.  I don't get the
>>> loading error I see through rake when I run this script in isolation
>>> (instead I get an error around the database not running which makes more
>>> sense cos it isn't).  I seem to have to go through a lot of hoop jumping to
>>> just create a Product using a spree Model.  Which makes me think either I'm
>>> doing it wrong or if the API isn't making it easy for me to do then I maybe
>>> I shouldn't be doing it at all.

>>> I feel like I'm missing something here - I'm sure there's an easier
>>> "Railsy" way to do this.

>>> Anyone got any pointers?

>>> Cheers

>>> Ben

>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Spree" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> msg/spree-user/-/QvFOlcgREisJ<https://groups.google.com/d/msg/spree-user/-/QvFOlcgREisJ>
>>> .
>>> To post to this group, send email to spree-user@googlegroups.com.
>>> To unsubscribe from this group, send email to spree-user+unsubscribe@**
>>> googlegroups.com <spree-user%2Bunsubscribe@googlegroups.com>.
>>> For more options, visit this group at http://groups.google.com/**
>>> group/spree-user?hl=en <http://groups.google.com/group/spree-user?hl=en>
>>> .

>>  --
> You received this message because you are subscribed to the Google Groups
> "Spree" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/spree-user/-/m4d2D4rP0jUJ.

> To post to this group, send email to spree-user@googlegroups.com.
> To unsubscribe from this group, send email to
> spree-user+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/spree-user?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.