RestfulX over Spree

8 views
Skip to first unread message

Bruno

unread,
Nov 2, 2009, 7:23:03 PM11/2/09
to Spree, scap...@gmail.com
Hi everybody,

I'm a french student in IT.

With a classmate, we are working on a online store using RoR and some
Flex views.
Actually, we are very interested by the Spree framework and we are
looking to RestfulX to see if we can accelerate the development.

We just want to overlap store views (client views) with Flex views
generated using RestfulX.
RestfulX need a model description in YML format and there is a
additional rake task which permit to get his YML description from an
existing Rails application (based on the shema.rb file).
Then we would need to override existing controllers to turn them into
REST CRUD controllers.

So before to enter further development, I just want to get some advice
or any feedback.
I see that some people succeeded to mix Spree and Flex, but we seem to
be the first to test such a tricky way of merging two powerful
framework together.

We will give you more details step after step.


Regards,

Bruno.

"Ing . Marcos Luís Ortíz Valmaseda"

unread,
Nov 2, 2009, 1:44:00 PM11/2/09
to spree...@googlegroups.com, bruno.l...@gmail.com, scap...@gmail.com
Bruno escribió:
I want to tell you that is a very successfull way to build a online
store with Flex and Spree.
First: You have to gain a Web 2.0 solution with all requirements that 's
implies, and this is a important
aspect to have in mind.
Second: You have to gain a marvelous and different application using
Flex and Spree, due to
both technologies are on the top of the web development on these days.
Everyone want a Flex/ Rails
application, look at for the jobs relationed with that,

Third: Spree is a excellent application directed for all international
standar for the E-Commerce,
for that reason you have many points to choose it like your base app to
build a successfull project
and Flex can give you excellent views for it.

For examples you can check this pages:
http://www.flex.org/ruby
http://flexonrails.org
http://www.railsinside.com/

Regards


--
--
"For me, the purpose is, at least partly, to have joy. Programmers often
feel joy when they can concentrate on the creative side of programming,
so Ruby is designed to make programmers happy."
Yukihiro Matsumoto (Matz), Creator of the Ruby Language

Ing. Marcos Luís Ortíz Valmaseda
System DBA && Rails New User
Centro de Tecnologías de Almacenamiento y Anális de Datos (CENTALAD)
Universidad de las Ciencias Informáticas

Linux User # 418229

http://www.freebsd.org
http://www.postgresql-es.org
http://www.postgresql.org
http://www.planetpostgresql.org
http://www.rubyonrails.org
http://www.ruby-lang.org

Sean Schofield

unread,
Nov 2, 2009, 9:06:58 PM11/2/09
to spree...@googlegroups.com
I'm pretty sure people have successfully used Flex with Spree although
I personally have not tried it.

You should know that Wynn and I are working on providing theme support
in Spree soon. In fact, we're pair programming on this tomorrow. I
mention this because we are going to start providing a "default" theme
and we'll be explicitly separating the front end views from all of the
back end stuff (which will remain tucked away in the spree gem.)

When we're done, it should be even easier to provide alternate views
(Flex, HAML, etc.) for Spree. Spree's most important feature is the
admin interface and data model (along with its overall flexibility.)
We've always imagined that developers would be reworking the front end
to suit their taste.

Sean Schofield

-------------------------------------------
Rails Dog LLC
2 Wisconsin Circle, Suite 700
Chevy Chase, MD 20815
voice: (301)560-2000
-------------------------------------------

Buzzware

unread,
Nov 4, 2009, 8:37:56 PM11/4/09
to Spree
Bruno,

thanks for drawing our attention to restfulx. I'm a Flex and Rails
developer and hadn't seen it until now.
It looks awesome, and I'll most likely use it with Spree and other
Rails apps in the near future.
I like the idea that to build an admin backend I only have to enable
rest in rails, insert the swf in the
backend, and I can do anything within Flex without integration with
the app UI itself.

Cheers

Gary

bruno le hyaric

unread,
Nov 10, 2009, 3:20:24 PM11/10/09
to Spree, scapoual
Hi,

We are on the way to build a Spree/RestfdulX application.
We started based on an instance of Spree (cf boot modes, git clone
'spree-repo').
Then wa have setup our taxonomies and product properties and now we
want to use the powerful flex view generators from RestfulX.

We have made a first tentative where we generate views for the entire
data model of Spree.
For more details, these generated views offers classical CRUD
operations for each class of the data model.

But the data model of Spree is pretty big and we just want to make the
store looking good for the end customer.

So, we are trying to identify only the necessary classes for store views.

* Is there any data model description (or class diagram) in the documentation?
If you confirm me that the db/model.rb is the reference concerning the
data model, I could imagine to build a class-diagram generator based
on it...

And by the way, we have other questions :

* Is there someone to manage full internationalisation for the full
spree application? For the moment, only labels seems to be translated,
right?


Best regards,

Bruno & Pascal.

2009/11/3, Bruno <bruno.l...@gmail.com>:

Alexander Negoda

unread,
Nov 10, 2009, 5:08:49 PM11/10/09
to spree...@googlegroups.com


2009/11/11 bruno le hyaric <bruno.l...@gmail.com>


Hi,

We are on the way to build a Spree/RestfdulX application.
We started based on an instance of Spree (cf boot modes, git clone
'spree-repo').

It will be open-source?
If yes, I wish to join working out

Alexander 

Bruno

unread,
Nov 10, 2009, 5:40:01 PM11/10/09
to Spree, scap...@gmail.com
Hello Alexander,

Thank you for your interest!

We are working on a personal online store project.
But our goal is to isolate a generic RestfulXOverSpree skeleton from
the final solution.
We plan to put this generic solution as an open source project but for
the moment we don't have time to initialize this project.

So we are discussing with developpers from Spree and RestfulX (on each
mailing lists) to get advices, information and ask questions...

You are welcome to join the discussion!


Regards,

Bruno & Pascal.



Alexander Negoda a écrit :

Alexander Negoda

unread,
Nov 11, 2009, 2:26:18 PM11/11/09
to spree...@googlegroups.com
I have begun today job over integration spree and restfulx. I try to integrate the flex-application as spree-extension. 
As the most simple variant I see such decision:
1 to develop in ~/dev-restfulx-app
2. To create new spree-expansion flex_ext
2. After swf-file compilation to transfer all files from ~/dev-restfulx-app in SPREE_APP/extensions/flex_ext

To conduct working out in folder SPREE_APP/extensions/flex_ext, it is required to change restfulx-> a rake-file 
Other decision does not come to mind...
You to what way have gone you?

Sean Schofield

unread,
Nov 11, 2009, 3:11:38 PM11/11/09
to spree...@googlegroups.com
There has been talk of a generic REST interface for Spree. Right now
we're heads down a major project and working on other stuff like
theming and search. We'll probably have an officially documented
interface eventually - in the meantime, I definitely encourage people
working together and discussing. Perhaps we can even leverage what
you come up with.

Sean Schofield

-------------------------------------------
Rails Dog LLC
2 Wisconsin Circle, Suite 700
Chevy Chase, MD 20815
voice: (301)560-2000
-------------------------------------------



Bruno

unread,
Nov 12, 2009, 1:51:06 PM11/12/09
to Spree, scapoual
Alexander, here is the way we followed to test RestfulX on the whole
Spree application :

# clone Spree repository
git clone git://github.com/railsdog/spree.git spree

# copy database.yml.example to database.yml
cd spree
cp config/database.yml.example config/database.yml

# generate Spree rails project
rake db:bootstrap

# install the restfulx gem
sudo gem install restfulx

# edit config/environment.rb
vim config/environment.rb
# add the lines bellow :
# RAILS_GEM_VERSION = 'x.x.x' unless defined? RAILS_GEM_VERSION
(here: x.x.x = 2.2.3)
# config.gem "restfulx"

# run the rx_config generator
./script/generate rx_config

# upadate schema.rb
rake db:schema:dump

# next steps are only for existing Rails application

# modify /usr/local/lib/ruby/gems/1.8/gems/restfulx-1.2.4/lib/restfulx/
rails/schema_to_yaml.rb because of a nil object exception => l.87 and
l.90
# change : "last_in_array_fix = last_in_array_fix.gsub(', ','')" to
"last_in_array_fix = last_in_array_fix.gsub(', ','') unless
last_in_array_fix.nil?"
# and : "schema << " - belongs_to: [#{belong_tos}]\n"" to "schema << "
- belongs_to: [#{belong_tos}]\n" unless last_in_array_fix.nil?"
# generate model.yml from schema.rb
rake db:schema:to_yaml

# Modify the ActionScript model cause Belong_tos don't comply with the
Ruby model.
# Change the generated file model.yml (l. 162) => "- belongs_to:
[group]" to "- polymorphic: [group]"

# create the restfulx scaffold for flex app
./script/generate rx_yaml_scaffold --flex-only

rake db:refresh

# Create the following files in app/flex/spree/models :
# - BillAddress :
#package spree.models {
# [Resource(name="bill_addresses")]
# [Bindable]
# public class BillAddress extends Address {
# public static const LABEL:String = "firstname";
# }
#}
# - ShipAddress :
#package spree.models {
# [Resource(name="ship_addresses")]
# [Bindable]
# public class ShipAddress extends Address {
# public static const LABEL:String = "firstname";
# }
#}
# - CreditcardPayment :
#package spree.models {
# [Resource(name="creditcard_payments")]
# [Bindable]
# public class CreditcardPayment extends Creditcard {
# public static const LABEL:String = "number";
# }
#}

# set the mxml compiler into the path then compile the flex app then,
rake rx:flex:build




Effectively, we think we should use Spree extension to separate
RestfulX stuff.
And we are wondering if it's possible to launch RestfulX generation
directly in the Spree extension folder...
We also need to select only some part of the data model of Spree (we
selected following main classes : Products, Users and Taxonomy).
Then it should be necessary to develop REST services over Spree (in
the same extension or in a 2nd extension).
We are looking to build a special generic RESTful controller (like
Sean's idea).
In fact we take a look on the internal mechanisms of RestfulX. There
is a RxModel class from which derivate all model objects, and this
class provide generic REST service call... (following the Rails
convention : http://server/controller/action/id.xml)
Following the same pattern, we think the best way is to have a single
controller in Spree which receive request from several routes :

http://server/users/1.xml
http://server/products/new.xml
...

This contoller must be able to determine the good object model from
the current route and return the object XML description using
ActiveRecord.Serialization.to_xml().
More over, this method permit to build complex XML response like
this :

format.xml @order.to_xml(:include=>@user)

to get something like that :

<order>
<order_property1> ... </order_property1>
....
<user>
<user_property1> ... </user_property1>
...
</user>
</order>

Anf finally, we are wondering if it's possible to restrict this super
generic Controller only to desired Models using routes.rb...

This is what we plan to try to develop next week.

You can have a look on RestfulX mailing list too.
http://groups.google.com/group/restfulx-framework/browse_thread/thread/c440c02b654e4c7d


Regards,

Bruno & Pascal.

Bruno

unread,
Nov 16, 2009, 5:10:31 PM11/16/09
to Spree
Hi,

I get stucked on a RubyGems problem while trying to use the RestfulX
gem.

In a spree application installed from gem, the RestfulX is not
'visible'.
But it's visible from a spree application cloned (git clone ...).

Why?

I have a look on differences between Spree config/boot.rb and Rails's
one.

You can reproduce my problem like this :

$gem install restfulx

$spree spree_shop
$cd spree_shop
$script/console
$gem 'restfulx'
=> false


$rails rails_application
$cd rails_application
$script/console
$gem 'restfulx'
=> true


Regards,

Bruno.

Bruno

unread,
Nov 16, 2009, 5:26:51 PM11/16/09
to Spree
Arf, sorry! I'm new to rubygems and I was wrong in my last mail...

$spree spree_shop
$cd spree_shop
$script/console
$gem 'restfulx'
=> false # normal because Spree has already loaded it at
boot time (config/environment.rb, + config.gem 'restfulx')

So RestfulX is loaded succesfully but RestfulX tasks and generators
aren't visible...

Any Idea?

Bruno

unread,
Dec 10, 2009, 5:29:26 AM12/10/09
to Spree
Hi,

i'm still working on mixing Spree with Flex views generated by
Restfulx.

I follow this approch :

* Create a top level directory :
$ mkdir prototype

* Create a spree application inside :
$ cd prototype
$ spree spree

* Create a independant rails application for restfulx :
$ cd ../
$ rails restfulx

I'm working on Ubuntu (linux system), so I can use filesystem links to
link restfulx application to spree database (spree/db) and models (app/
models)...

Then I'm in trouble because spree models seem's to have a lot of
dependencies (AttributeFu and so on...) which are separated plugins...
So I need to fix dependencies issues in the restfulx application
environment.rb.

In fact I realize that my problem consists in merging to rails app
configuration : the configuration from Spree, and the one from my
rails application dedicated to restfulx.
An I'm looking for the smarter way to do that.

I'm waiting for a engine-based spree (perhaps in Rails 3.0). Is there
any progression in that way...
Or in other words, what are the locks which avoir us to build a Spree
engine?
I could help for this work because I really think it will resolve my
problem of configuration encapsulation...


Regards,

Bruno.

-------------------------------------------------------------------------------------------------------------------------------------
Spree mailing list, this topic :
http://groups.google.com/group/spree-user/browse_thread/thread/4797e45d712b1c8a?hl=en
RestfulX mailing list, this topic :
http://groups.google.com/group/restfulx-framework/browse_thread/thread/c440c02b654e4c7d?hl=en
Reply all
Reply to author
Forward
0 new messages