Master *will* break your code

83 views
Skip to first unread message

Ryan Bigg

unread,
Nov 5, 2011, 10:55:09 AM11/5/11
to spree...@googlegroups.com
Hello friends,

tl;dr: namespace branch will be merged into master soon. This will most likely break any application using master branch. Please try namespace branch and report issues.

This thread should provide ample advanced warning on this breakage.

This week when I return to Australia from Ukraine on Tuesday afternoon (Early Monday morning American), I will be merging the namespace branch into the master branch. I explain the benefits of the namespacing work in this thread: http://groups.google.com/group/spree-user/msg/af44fbdb7e401b8e. It's for the greater good. I promise!

The bad news is that this *will* break your application and extensions if you're using Spree master. This is because things such as the model formerly known as Product is now called Spree::Product, and so on like that. 

What I'd like you to do is to try out your applications on the *namespace* branch and report back any problems as you come across them. After Tuesday, I would ask that you switch over to the master branch once again and continue working on that.

Thank you!
Ryan Bigg


Chris

unread,
Nov 6, 2011, 1:37:33 AM11/6/11
to spree...@googlegroups.com
Ryan,

Doing a fresh install using the namespace branch creates a
products_promotion_rules table that doesn't have the spree_ prefix. I
assume this is an oversight.

Chris

> --
> 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,
Nov 6, 2011, 1:19:29 AM11/6/11
to spree...@googlegroups.com
Thanks for pointing this out Chris, I've fixed it in this commit: https://github.com/spree/spree/commit/29bc416203b08ef0e9293cb49169fefb0e0187c6

Chris

unread,
Nov 6, 2011, 3:23:15 AM11/6/11
to spree...@googlegroups.com
Next problem. This is the error that I get on a fresh install when
trying to go to http://localhost:3000

[2011-11-06 17:14:17] INFO WEBrick 1.3.1
[2011-11-06 17:14:17] INFO ruby 1.9.2 (2011-07-09) [x86_64-darwin11.0.0]
[2011-11-06 17:14:17] INFO WEBrick::HTTPServer#start: pid=69540 port=3000

Started GET "/" for 127.0.0.1 at 2011-11-06 17:16:14 +0900
ActionController::RoutingError (No route matches [GET] "/"):

The steps that I followed to create the app (using the namespace
branch, including the commit 29bc416203b08ef0e9293cb49169fefb0e0187c6)

1) rails new junk
2) add (gem 'spree', :path => '/path/to/namespaced/spree/clone') to the Gemfile
3) bundle install
4) rails g spree:site
5) bundle exec rake db:migrate
6) bundle exec rake db:seed
7) open web browser and go to http://localhost:3000

So what am I missing?

Thanks,
Chris

Ryan Bigg

unread,
Nov 6, 2011, 3:28:46 AM11/6/11
to spree...@googlegroups.com
I *just* noticed that myself also!

The issue was that the Getting Started guide does not mention that you need to mount the engine in your routes file.

It is done with this line:

mount Spree::Core::Engine, :at => "/"

It is done this way now because you may want to mount it at things like "/shop".

I'll open an issue to update the Getting Started guide.

Chris

unread,
Nov 6, 2011, 3:43:17 AM11/6/11
to spree...@googlegroups.com
OK, I like the ability to move it around, now on to the next problem:

Rendered core/app/views/spree/shared/_nav_bar.html.erb (2423.7ms)
Completed 500 Internal Server Error in 3162ms

ActionView::Template::Error (undefined local variable or method
`spree_auth' for #<#<Class:0x007ff8f72232b8>:0x007ff8f721d1d8>):
4: <li><%= link_to t(:my_account), spree_auth.account_path %></li>
5: <li><%= link_to t(:logout),
spree_auth.destroy_user_session_path %></li>
6: <% else %>
7: <li><%= link_to t(:log_in), spree_auth.login_path %></li>
8: <% end %>
9: <% if store_menu? %>
10: <%= render :partial => 'spree/shared/store_menu' %>

I'm thinking I should wait a while longer before messing with it. I
was hoping to start modifying my personal extensions to work with it,
but it looks like I may want to wait a while.

Chris

Ryan Bigg

unread,
Nov 6, 2011, 4:05:56 AM11/6/11
to spree...@googlegroups.com
I am unable to reproduce this issue. What were the steps you used to get to that stage? In my example application the login bar just is not showing at all.

Chris

unread,
Nov 6, 2011, 4:56:51 AM11/6/11
to spree...@googlegroups.com
It's the same application from my previous post. I just added the

mount Spree::Core::Engine, :at => "/"
to the routes.rb file.

Chris

Chris

unread,
Nov 6, 2011, 5:14:58 AM11/6/11
to spree...@googlegroups.com
I just re-created a new test app using the same steps as I listed
below just to make sure that I didn't accidentally screw anything up
and I still get the same error.

I'm using Ruby 1.9.2 if that makes a difference. Although that's what
I've been using ever since it was released without any known issues.

Chris

Ryan Bigg

unread,
Nov 6, 2011, 5:42:36 AM11/6/11
to spree...@googlegroups.com
Ah, I was using 1.9.3. It turns out that there may be an issue with Deface with 1.9.3, as the overrides are being loaded, but the view templates are not appearing. I will use 1.9.2 for now and attempt to figure out the 1.9.3 issue later.

So yeah, the version number *does* make a difference :)

Ryan Bigg

unread,
Nov 6, 2011, 5:51:28 AM11/6/11
to spree...@googlegroups.com
Your issue about not having the "spree_auth" helper is because you will also need to mount the Spree::Auth::Engine class:

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

I will be making a helper for this after the merge to master, so that you will be able to do this in your routes:

Rails.application.routes.draw do
  spree
  # your routes go here
end

Then we would be able to customise the controllers for this, again in much the same way Devise does:

Rails.application.routes.draw do
  spree, :controllers => { :products => "products" }
end

Spree will automatically know that the controller *should* be "spree/products" by default, but by using the :controllers option here you can tell it that "actually no, please use this *other* controller", and it will do that. This new controller should inherit from Spree's ProductsController (Spree::ProductsController):

class ProductsController < Spree::ProductsController

end

Then you can override it in there.

Sound good?

Chris

unread,
Nov 6, 2011, 6:18:05 AM11/6/11
to spree...@googlegroups.com
Ryan,
Sorry, I must not have been clear. I did add the mount
Spree::Auth::Engine, :at => '/' to the routes.rb file. My routes.rb
file looks like this (minus the comments).

Junk::Application.routes.draw do


mount Spree::Core::Engine, :at => "/"

end

I assume that is correct.

Chris

Ryan Bigg

unread,
Nov 6, 2011, 6:25:08 AM11/6/11
to spree...@googlegroups.com
You need to mount both the engines at the moment:

Junk::Application.routes.draw do
  # Your routes go here
  mount Spree::Auth::Engine, :at => '/'
  mount Spree::Core::Engine, :at => '/'
end

The order is important because Spree::Core has a catch-all route at the end of it.

Chris

unread,
Nov 6, 2011, 6:33:00 AM11/6/11
to spree...@googlegroups.com
AHHHHH! My bad. I didn't even notice that we were talking about the
different parts of Spree. I guess I should have paid closer attention
to what you wrote.

That works for now. I'll let you know if I run into anything else.

Thanks,
Chris

Ryan Bigg

unread,
Nov 6, 2011, 7:35:23 AM11/6/11
to spree...@googlegroups.com
No worries! You're allowed to make mistakes, please do not apologise for being human.

Really interested to hear of any other problems you run into while upgrading your application to the latest namespace changes. You've been helpful so far :)

Chris

unread,
Nov 6, 2011, 10:35:23 AM11/6/11
to spree...@googlegroups.com
Ryan,
Well, I just hit another show stopper for me. I'm using the
routing-filter gem ( https://github.com/svenfuchs/routing-filter )
which causes the same error that I was getting before when I didn't
have the ( mount Spree::Auth::Engine, :at => '/' ) commands in my
route.rb file.

ActionController::RoutingError (No route matches [GET] "/"):

The routing-filter gem works great for me with Spree 0.70.x.

NOTE: It fails just by adding the routing-filter gem to the Gemfile,
no configuration changes are needed to cause it to fail.

I wish I could be more help tracking this stuff down for you, but I
still don't fully understand how all the mountable apps stuff works.

Chris

Tomek "Tomash" Stachewicz

unread,
Nov 6, 2011, 4:17:20 PM11/6/11
to spree...@googlegroups.com
Excuse the offtopic, but by the way: aren't you having double locale-prefixes with routing-filter? That was quite an issue for me when evaluating using this awesome gem (used it for bitspudlo.com previous engine) with Spree :/ 

Also to stay ontopic: I hope there'll be an upgrade guide on how to make namespaced Spree working as before (i.e. application's main functionality, with the same routes etc.)? :) 

Tomash

Chris

unread,
Nov 6, 2011, 7:37:42 PM11/6/11
to spree...@googlegroups.com
Tomash,
I don't have the double locale prefixes, just a single locale entry.
That problem does sound familiar though, so I may have figured out
how to get around it. I integrated the routing-filter code quite a
while ago so I don't really remember. I'm also using it to inject
some additional info without any problems. At least until I tried it
with the namespaced branch :-)

If fails on the namespaced branch even before adding my extension to
the mix. Pure namespaced branch and the routing-filter gem causes
Spree's routing to stop working. I REALLY need a solution to this
though because losing the routing-filter gem is not an option for my
project.

Chris

> --
> 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/-/zu_RXBDmWi4J.

Ryan Bigg

unread,
Nov 6, 2011, 10:19:27 PM11/6/11
to spree...@googlegroups.com
Chris: Could you give an example of how you're trying to use this gem? You may have to apply the routing filters to the engines rather than the application, although I am not sure at this point in time.

Chris

unread,
Nov 6, 2011, 11:01:46 PM11/6/11
to spree...@googlegroups.com
The simplest part of how I am using it is the "filter :locale" command
that is placed in the application routes.

Rails.application.routes.draw do
# Add your extension routes here
filter :locale
end

Although that line of code is happening in an extension that I haven't
even included yet. At this point just placing the routing-filter gem
in the Gemfile causes Spree to break.

This doesn't happen on the master branch, just the namespace branch.
I assume it has something to do with the isolation for mountable apps.

I'm also doing some more complicated route changes with my own custom
filter, but again, I haven't even put that extension in the gemfile
yet.

The documentation for routing-filter isn't great, but it can be found here:
https://github.com/svenfuchs/routing-filter

Basically it will prepend the locale to the urls that are created, and
then strip them off before the app sees them. So it allows me to have
unique urls for the different languages and as far as Spree knows the
change never happened. So the Spree code continues to use the normal
rails url generation methods without needing to be tweaked to pass in
the locale parameter.

My custom filters are more complicated, but the idea is the same.

Thanks again,
Chris

Sean Schofield

unread,
Nov 7, 2011, 10:55:49 AM11/7/11
to spree...@googlegroups.com
> I'll open an issue to update the Getting Started guide.

Ryan, you should also have direct commit access to the guides (FYI).

Ryan Bigg

unread,
Nov 8, 2011, 8:23:32 PM11/8/11
to spree...@googlegroups.com
Indeed I do. I've just fixed an issue with one of the guides and will investigate the necessary namespace changes once things get stable(r) on master.

On Tuesday, 8 November 2011 at 2:55 AM, Sean Schofield wrote:

I'll open an issue to update the Getting Started guide.

Ryan, you should also have direct commit access to the guides (FYI).

Reply all
Reply to author
Forward
0 new messages