migrating from 0.70 to 1.00.0rc2 - my steps, errors and fixes

284 views
Skip to first unread message

Steve Root

unread,
Jan 22, 2012, 7:04:11 AM1/22/12
to Spree
Hi all,

For the benefit of others, here are my steps, the errors I came
across, and the solutions, when migrating my site from 0.70 to
1.00.0rc2.

These steps have taken me to an updated site that has a working front
end. I hadn't set up the order/cart processing on 0.70, so there may
be more to do there. There also appears to be one issue left with the
CSS (I'll update later).

Hope it saves someone some time.
Steve


Notes from going from Spree 0.70.3 to Edge (1.0.0.rc2)

1)
Add the version of the Gem in Gemfile
was:
gem 'spree'
(Note to self: Probably not a good idea not to have the spree version)
Now:
gem 'spree', :git => 'git://github.com/spree/spree.git'

Activated change by: bundle update // bundle install

2)
rails s
generates error:
uninitialized constant RedirectLegacyProductUrl (NameError)
Fix https://github.com/spree/spree/issues/848
Radar says
This error would happen if you generated the application initially
using:
rails g spree:site
This inserts lines beginning with config.middleware into config/
application.rb that aren't compatible with the edge version of Spree.
To fix this, remove these two lines and try again.

3)
rails s
generates error:
Missing helper file helpers/products_helper.rb (LoadError)

Issue was I had spree_static_content selecting the 0.70 branch. Change
Gemfile to:
gem 'spree_static_content',
:git => 'http://github.com/spree/spree_static_content',
:branch => 'master'

Activated change by: bundle update // bundle install

4)
rails s
generates error:
/Users/steve/Documents/ruby/spree1/app/models/image_decorator.rb:1:in
`<top (required)>': uninitialized constant Image (NameError)

That's a decorator i added.
Changes from 0.70 to 1.00 on github show the only change was the
removal of the first line "module spree".. before "class Image <
Asset"

Need to put "Spree::" before the model, so a line like:
Image.attachment_definitions[:attachment][:styles] = { :mini =>
'48x48>', :small => '150x120>', :product => '240x240>', :large =>
'600x600>' }
becomes:
Spree::Image.attachment_definitions[:attachment][:styles] = { :mini =>
'48x48>', :small => '150x120>', :product => '240x240>', :large =>
'600x600>' }

5)
rails s works!
open site - RoutingError (no route matches / or /admin)

Fix described in:
http://groups.google.com/group/spree-user/browse_thread/thread/cd65247f5dece15d/9910355c8b034934?lnk=gst&q=no+route+matches#9910355c8b034934

The new approach needs spree to be mounted in the routes, which allows
the spree site to be somewhere like mydomain.com/shop . In routes.rb,
add the following for spree to be the default site.

mount Spree::Auth::Engine, :at => '/'
mount Spree::Core::Engine, :at => '/'

order of above is important.

### probably worked, got a new error! ###


6) Error when opening site http://localhost:3000

Mysql2::Error: Table 'spree1_development.spree_product_groups' doesn't
exist: SHOW FIELDS FROM `spree_product_groups`

Engines don't automatically copy their migrations, do just 'rake
db:migrate' isn't sufficient.
See http://guides.spreecommerce.com/getting_started.html 4.5
Installing the migrations

I assume the 'rails g spree:site' needs to be the same as the original
rails g command used. I've forgotten, but I probably used it exactly
as the manual said…

So in directory, run:
rails g spree:site

###HINDSIGHT###
Could have run: rails g spree:install --migrate=true --sample=false --
seed=false
###############

There are some conflicts to think on: (nb: d = show diff - useful!)
6a)
conflict config/spree.yml
#This contains the spree version… Allowing (Y)

6b)
conflict app/assets/javascripts/store/all.js
# said yes

6c)
conflict app/assets/javascripts/admin/all.js
# said yes

6d)
conflict app/assets/stylesheets/store/all.css
# said yes… may need to revisit this if my styles aren't working

6e)
conflict app/assets/stylesheets/admin/all.css
# said yes.. new require of formtastic (might be notable later..)

6f) Some interesting output, that may relate to problems I'm just
about to discover:
###############
rake db:seed
rake aborted!
No such file or directory - (/Users/steve/Documents/ruby/spree1/tmp/
cache/00020120121-28142-third1, /Users/steve/Documents/ruby/spree1/tmp/
cache/001/000/)

Tasks: TOP => db:seed => db:abort_if_pending_migrations => environment
(See full trace by running task with --trace)
loading sample data
insert config/routes.rb
**************************************************
We added the following line to your application's config/routes.rb
file:

mount Spree::Core::Engine, :at => '/'
**************************************************
Spree has been installed successfully. You're all ready to go!

Enjoy!
DEPRECATION WARNING: rails g spree:site has been deprecated and will
be removed in the future, use rails g spree:install instead. (called
from run_install_generator at /Users/steve/.rvm/gems/ruby-1.9.2-
p290@spreerc/bundler/gems/spree-7d213829038c/lib/generators/spree/site/
site_generator.rb:15)
####################

SO… i've removed the "mount Spree::Core::Engine, :at => '/'" and
"mount Spree::Auth::Engine, :at => '/'" as the Core was duplicated and
the Auth wasn't added (so I'm assuming it wasn't necessary).

SO… db:seed failed, but I already have content… maybe it was smart
enough not to overwrite my data, though I'm not sure what the missing
cache comes from.

SO…. rails g spree:install - is something for the future, but is a
warning only.

SO… migrations appear to run automatically…

but running "rails s" results in error: No such file or directory - (/
Users/steve/Documents/ruby/spree1/tmp/cache/00020120121-44273-9sketb, /
Users/steve/Documents/ruby/spree1/tmp/cache/001/000/) (Errno::ENOENT),
same error when running rake db:migrate

Idea: Cache should be created on demand. Maybe the rake is checking
things are up to date but they've not been created yet. in tmp/cache:
rm -rf * (to delete the contents)

Didn't help. Tried: rails g spree:install --migrate=true --
sample=false --seed=false
- didn't help (same error)

Noticed: running rake db:migrate creates a directory 001 in the tmp/
cache directory then errors. Every error is for a different directory,
e.g. this one for: /Users/steve/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/
1.9.1/fileutils.rb:515:in `rename': No such file or directory - (/
Users/steve/Documents/ruby/spree1/tmp/cache/00020120121-51147-ncl84k, /
Users/steve/Documents/ruby/spree1/tmp/cache/001/000/)
It errors on rename. Suggests cache 00020….etc didn't get created.
What migration would create a tmp file?

Made the sub directory tmp/001/000
(tmp/001 was created. I guess spree didn't want to create 000)

Migrations run OK, same message about Spree::Core::Engine, but it's
not been duplicated.

7) localhost:3000/admin works, but localhost:3000 errors with: 'no
such file to load -- aws-skd (You may need to install the aws-sdk gem)
From Gemfile, removed:gem 'aws-s3'
Added: gem 'aws-sdk'

8) Deface customisations to footer and sidebar not working.
Virtual Paths need to change, e.g. from:
:virtual_path => "layouts/spree_application",
to:
:virtual_path => "spree/layouts/spree_application",

9) New Error
uninitialized constant ActionView::CompiledTemplates::Page

Extracted source (around line #3):
1: <li id="home-link" data-hook><%= link_to t(:home), root_path %></
li>
2: <li id="link-to-cart" data-hook><%= link_to_cart %></li>
3: <% for page in Page.header_links do %>
4: <li><%= link_to page.title, page.link %></li>
5: <% end %>

This comes from one of my Deface overrides, adding pages from the
spree_static_page
First guess: Need to get migrations for namespacing,
rails g spree_static_content:install
Nope, appears they already run.
(Hindsight: I could have checked if the database had table:spree_pages
instead of table:pages)

Second Guess: The object is no longer called 'page', perhaps it's
spree::page or similar…

Solved, replace things like:
<% for page in Page.sidebar_links do %>
with
<% for page in Spree::Page.sidebar_links do %>

10) CSS issue?
Menu on left, headings are black and not yellow...

Steve Root

unread,
Jan 22, 2012, 8:57:07 AM1/22/12
to Spree
10) Menu customisations and styles not working
Wasn't a CSS Issue. Rather than Deface the change, I replace the
whole template. The new layout means that was was in:
app/views/shared
Now needs to be in:
app/views/spree/shared
(which also affected a product view, and within that product view file
<%= render :partial => 'shared/taxonomies' %>
became
<%= render :partial => 'spree/shared/taxonomies' %>


On Jan 22, 12:04 pm, Steve Root <st...@rkbb.co.uk> wrote:
> Hi all,
>
> For the benefit of others, here are my steps, the errors I came
> across, and the solutions, when migrating my site from 0.70 to
> 1.00.0rc2.
>
> These steps have taken me to an updated site that has a working front
> end. I hadn't set up the order/cart processing on 0.70, so there may
> be more to do there.  There also appears to be one issue left with the
> CSS (I'll update later).
>
> Hope it saves someone some time.
> Steve
>
> Notes from going from Spree 0.70.3 to Edge (1.0.0.rc2)
>
> 1)
> Add the version of the Gem in Gemfile
> was:
>  gem 'spree'
> (Note to self: Probably not a good idea not to have the spree version)
> Now:
> gem 'spree', :git => 'git://github.com/spree/spree.git'
>
> Activated change  by: bundle update // bundle install
>
> 2)
> rails s
> generates error:
>  uninitialized constant RedirectLegacyProductUrl (NameError)
> Fixhttps://github.com/spree/spree/issues/848
> Fix described in:http://groups.google.com/group/spree-user/browse_thread/thread/cd6524...
>
> The new approach needs spree to be mounted in the routes, which allows
> the spree site to be somewhere like mydomain.com/shop . In routes.rb,
> add the following for spree to be the default site.
>
>   mount Spree::Auth::Engine, :at => '/'
>   mount Spree::Core::Engine, :at => '/'
>
> order of above is important.
>
> ### probably worked, got a new error! ###
>
> 6) Error when opening sitehttp://localhost:3000

Sean Schofield

unread,
Jan 23, 2012, 10:15:08 PM1/23/12
to spree...@googlegroups.com
Thanks for sharing your detailed notes. We're hoping to improve the
docs before release time but your notes will be helpful until then
(and perhaps influence the final docs.)

Sean

> --
> You received this message because you are subscribed to the Google Groups "Spree" group.
> To post to this group, send email to spree...@googlegroups.com.
> To unsubscribe from this group, send email to spree-user+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.
>

Ryan Bigg

unread,
Jan 23, 2012, 10:36:44 PM1/23/12
to Spree
TL;DR.

Just kidding! :) This is quite thorough. Let me address each point as
we go:

1) (Upgrading Spree) You should just need to run `bundle update spree`
for this to upgrade Spree. If you run `bundle update` by itself you
run the chance of all the dependencies in your application being
updated to their absolutely latest versions (unless gem dependencies
are *explicitly* specified), and that can lead to things breaking. So
yeah, just `bundle update spree`.

2) Unfortunately this is unavoidable.. unless we add something like
`rails g spree:upgrade` which fixes up or calls out *small* things
like this. That'd be a good idea for a patch, actually. It's added
automatically now inside Spree::Core::Engine (https://github.com/spree/
spree/blob/master/core/lib/spree/core/engine.rb#L8), and so you don't
need this line anymore.

3) Correct, you'll need to update extensions to their 1.0.0
counterparts. There's work currently underway to upgrade extensions to
1.0.

4) Also correct. You'll need to update any decorators that were
decorating non-namespaced classes to now decorate their namespaced
counterparts. Product becomes Spree::Product and so on.

5) The new `rails g spree:install` will insert `mount
Spree::Core::Engine, :at => '/'` into `config/routes.rb` for the
application, meaning that it'll mount the engine correctly. Obviously,
this isn't going to "magically" appear in your application when you
upgrade to 1.0, so you'll need to add this line yourself.

No need for Spree::Auth::Engine as well, as this engine's routes just
extend Spree::Core::Engine (https://github.com/spree/spree/blob/master/
auth/config/routes.rb#L1).

6) With this one, you'll need to run `rake
railties:install:migrations` to copy over all the migrations from all
the "railties" (i.e. engines) that are included in your application.
This may also include any migrations from extensions. Then you'll need
to run `rake db:migrate` which'll update your database and solve this
problem.

I would strongly discourage the use of spree:install here as it may
override things you don't want it to override. Not so bad now that we
all use version control, yeah?

7) I don't know why this error is occurring inside Spree's admin
section. I suspect it may be an issue with your application? Perhaps
it's attempting to load something to do with AWS on that request?

8) Very similar to #4. You'll need to correct the paths to the
templates that you're overriding to include the Spree namespace.

9) Correct again. To do with namespacing also.

10) Also to do with namespacing.

---

And that rounds it out :) Thanks for taking the time to not only TRY
1.0.0, but write up the process as you went. Very happy to see that
most of the problems encountered dealt with namespacing and nothing
major blew up.

We'll look at putting this information into a guide soon. Thanks again
mate!


On Jan 22, 11:04 pm, Steve Root <st...@rkbb.co.uk> wrote:
> Hi all,
>
> For the benefit of others, here are my steps, the errors I came
> across, and the solutions, when migrating my site from 0.70 to
> 1.00.0rc2.
>
> These steps have taken me to an updated site that has a working front
> end. I hadn't set up the order/cart processing on 0.70, so there may
> be more to do there.  There also appears to be one issue left with the
> CSS (I'll update later).
>
> Hope it saves someone some time.
> Steve
>
> Notes from going from Spree 0.70.3 to Edge (1.0.0.rc2)
>
> 1)
> Add the version of the Gem in Gemfile
> was:
>  gem 'spree'
> (Note to self: Probably not a good idea not to have the spree version)
> Now:
> gem 'spree', :git => 'git://github.com/spree/spree.git'
>
> Activated change  by: bundle update // bundle install
>
> 2)
> rails s
> generates error:
>  uninitialized constant RedirectLegacyProductUrl (NameError)
> Fixhttps://github.com/spree/spree/issues/848
> Fix described in:http://groups.google.com/group/spree-user/browse_thread/thread/cd6524...
>
> The new approach needs spree to be mounted in the routes, which allows
> the spree site to be somewhere like mydomain.com/shop . In routes.rb,
> add the following for spree to be the default site.
>
>   mount Spree::Auth::Engine, :at => '/'
>   mount Spree::Core::Engine, :at => '/'
>
> order of above is important.
>
> ### probably worked, got a new error! ###
>
> 6) Error when opening sitehttp://localhost:3000

Steve Root

unread,
Jan 27, 2012, 8:55:31 AM1/27/12
to Spree


On Jan 24, 3:36 am, Ryan Bigg <r...@spreecommerce.com> wrote:
> TL;DR.

Lol!

>
> Just kidding! :) This is quite thorough. Let me address each point as
> we go:
<big snip>

7) localhost:3000/admin works, but localhost:3000 errors with: 'no
such file to load -- aws-skd (You may need to install the aws-sdk
gem)
From Gemfile, removed:gem 'aws-s3'
Added: gem 'aws-sdk'

> 7) I don't know why this error is occurring inside Spree's admin
> section. I suspect it may be an issue with your application? Perhaps
> it's attempting to load something to do with AWS on that request?

Sorry, I think my use of English confused it here ;-)
localhost:3000 did not work, due to needed to change the aws gem
(some product images on my dev environment are hosted on AWS)
localhost:3000/admin WORKED perfectly - I found no problems with
spree admin :-)

Thanks for taking the time to post corrections, it's taught me
things :-)

Steve

Steve Root

unread,
Jan 27, 2012, 11:27:02 AM1/27/12
to Spree
Update; the core CSS has had significant changes that happened here:

https://github.com/spree/spree/commit/4614bddf46f670dcc662a49cc86c9aa60c434a38

So for me I'll need to rework my layout from scratch or override them
Reply all
Reply to author
Forward
0 new messages