What is the Best practice?

12 views
Skip to first unread message

fry

unread,
Jan 29, 2010, 3:00:47 PM1/29/10
to Spree
== What is conventional way to develop sites based on Spree?

1. It's seems like creating an "extension" Site is recommended. And
what about source navigation?

2. And what about new functionality? I have to restart application
after each model/helper/controller edit? It's seems like that when
using overrides in "def activate" block of my site_extension. The same
story with js. It's really discouraging. What can you advise?

3. Testing page in documentation is completely empty )))) How can I
tests of my extension without all others?

After a week of developing my "site_extension" I realized, that it's
not a good idea to make large sites, based on Spree. It's not very
hard to install several third party extensions, but something else -
no thanks.

May be You know how to make it easier? :) Help me )))

Thank You!

Roman Smirnov

unread,
Jan 30, 2010, 4:24:42 PM1/30/10
to Spree

On Jan 29, 11:00 pm, fry <udalov.ser...@gmail.com> wrote:
> == What is conventional way to develop sites based on Spree?
>
> 1. It's seems like creating an "extension" Site is recommended. And
> what about source navigation?

What do you mean? I never had any problems with source navigation,
problem is clearly not in the Spree.

> 2. And what about new functionality? I have to restart application
> after each model/helper/controller edit? It's seems like that when
> using overrides in "def activate" block of my site_extension. The same
> story with js. It's really discouraging. What can you advise?

Just reload page twice. F5, F5 and no need to restart app.
As for js, then you can edit js-файлы in main public dir and just copy
them to your extension public folder after completing of editing.

> 3. Testing page in documentation is completely empty )))) How can I
> tests of my extension without all others?

Sometimes it is useful to at least read a list of available tasks
before angry.
`rake -T` will help you.

rake spec:extensions
# Runs specs on all available extensions in the current /vendor/
extensions directory, pass EXT=extension_name to test a single
extension

rake extensions:test
# Runs all tests on all available extensions in the current /vendor/
extensions directory, pass EXT=extension_name to test a single
extension

rake extensions:test:functionals
# Runs functional tests on all available extensions in the current /
vendor/extensions directory, pass EXT=extension_name to test a single
extension

rake extensions:test:units
# Runs unit tests on all available extensions in the current /vendor/
extensions directory, pass EXT=extension_name to test a single
extension

fry

unread,
Feb 1, 2010, 3:59:33 AM2/1/10
to Spree

1. What do you mean? I never had any problems with source navigation,

problem is clearly not in the Spree.

I mean, that most rails ide suppose, that rails code is in main app
dir. For example my rails.vim plugin can't help me to navigate through
my controllers and views.

2.Just reload page twice. F5, F5 and no need to restart app. As for


js, then you can edit js-файлы in main public dir and just copy them
to your extension public folder after completing of editing.

There are some problems: spree way is to extend base models with
class_eval in site_extension.rb. And modifications in this file
couldn't be visible without restart. And if I just copy all models in
my extension app dir, then all other extensions class_eval
modifications will be rewritten.

Your suggestion about js-файлах (дружище, привет из России :-) is
great, but it has one discouraging moment. After restarting server you
can loose all you modifications. So you have to keep it in mind, that
restarting the server is dangerous operation. Not good.

3. rake spec:extensions
It's really great, thank you. But, how can I use rspec server? It
doesn't work for me:

(dev)$ spec vendor/spree/spec/models/* --drb
(druby://127.0.0.1:8989) script/spec_server:33:in `run': undefined
method `cleanup_application' for #<ActionController::Dispatcher:
0xb571243c> (NoMethodError)

Roman Smirnov

unread,
Feb 1, 2010, 3:50:15 PM2/1/10
to Spree

On Feb 1, 11:59 am, fry <udalov.ser...@gmail.com> wrote:
> 1. What do you mean? I never had any problems with source navigation,
> problem is clearly not in the Spree.
>
> I mean, that most rails ide suppose, that rails code is in main app
> dir. For example my rails.vim plugin can't help me to navigate through
> my controllers and views.

Yup, it's not Spree problem, it's your IDE problem. :-)

>
> 2.Just reload page twice. F5, F5 and no need to restart app. As for
> js, then you can edit js-файлы in main public dir and just copy them
> to your extension public folder after completing of editing.
>
> There are some problems: spree way is to extend base models with
> class_eval in site_extension.rb. And modifications in this file
> couldn't be visible without restart. And if I just copy all models in
> my extension app dir, then all other extensions class_eval
> modifications will be rewritten.

You are wrong. Просто сделай как я написал, чтобы изменения в файлах
расширений вступили в силу сервер перезапускать не надо!!! Надо просто
послать 2 любых запроса к серверу, а не один, как в случае с измениями
в основном проекте.

> Your suggestion about js-файлах (дружище, привет из России :-) is
> great, but it has one discouraging moment. After restarting server you
> can loose all you modifications. So you have to keep it in mind, that
> restarting the server is dangerous operation. Not good.

Server restarting is very rare action. So this is not problem. Just
copy js files back to extension, as soon you got desired result by
modifications in main public dir, without waiting for a server
restart.

> 3. rake spec:extensions
> It's really great, thank you. But, how can I use rspec server? It
> doesn't work for me:
>
> (dev)$ spec vendor/spree/spec/models/* --drb
> (druby://127.0.0.1:8989) script/spec_server:33:in `run': undefined
> method `cleanup_application' for #<ActionController::Dispatcher:
> 0xb571243c> (NoMethodError)

I don't use rspec server.
The Spree Core Team abandoned RSpec in favor of TestUnit + Shoulda, so
you must dive into problem yourself, if you really need RSpec.

P.S. Вопросы по Spree на русском можно задавать на http://spreecommerce.ru/

fry

unread,
Feb 2, 2010, 3:21:05 AM2/2/10
to Spree
> Yup, it's not Spree problem, it's your IDE problem. :-)
I think this problem is very common. What editor you are using?

> Server restarting is very rare action. So this is not problem. Just
> copy js files back to extension, as soon you got desired result by
> modifications in main public dir, without waiting for a server
> restart.

Ok, I've got it. But this way makes restarting not only "rare", but
also dangerous.
And what about running tests or starting console session? We have the
same story: our public assets would be overwritten. You can instantly
restart your computer, you can forget about editing js and so on. And
git can't help you.

> I don't use rspec server.
> The Spree Core Team abandoned RSpec in favor of TestUnit + Shoulda, so
> you must dive into problem yourself, if you really need RSpec.

So don't I. But Spree generates spec dir for each new extension. And
You advised me to use command: rake spec:extensions. That's why I
thought, that rspec is main testing framework for spree. :)

Thank you!

> P.S. Вопросы по Spree на русском можно задавать наhttp://spreecommerce.ru/

Roman Smirnov

unread,
Feb 2, 2010, 7:07:00 AM2/2/10
to Spree

On Feb 2, 11:21 am, fry <udalov.ser...@gmail.com> wrote:
> > Yup, it's not Spree problem, it's your IDE problem. :-)
>
> I think this problem is very common. What editor you are using?

Basically gEdit. Besides, I can recommend RubyMine to all, who have
problems with navigation.

> > Server restarting is very rare action. So this is not problem. Just
> > copy js files back to extension, as soon you got desired result by
> > modifications in main public dir, without waiting for a server
> > restart.
> Ok, I've got it. But this way makes restarting not only "rare", but
> also dangerous.

Nothing dangerous, good text editor in extreme cases will ask you
before update overwritten files.
In general, the problem again not in the Spree, but in your experience
and in your text editor settings.

> And what about running tests or starting console session? We have the
> same story: our public assets would be overwritten. You can instantly
> restart your computer, you can forget about editing js and so on. And
> git can't help you.

You can temporary delete old version of js from your extension public
dir if you are so scattered.
В общем, не создавай из мухи слона, я за полгода активной работы со
Spree и с большим количеством расширений ни разу не столкнулся с
такими вымышленными проблемами, как потеря измений в js файлах из-за
рестарта сервера или необходимость перезапуска сервера, чаще чем для
других Rails приложений.

> > I don't use rspec server.
> > The Spree Core Team abandoned RSpec in favor of TestUnit + Shoulda, so
> > you must dive into problem yourself, if you really need RSpec.
>
> So don't I. But Spree generates spec dir for each new extension. And
> You advised me to use command: rake spec:extensions. That's why I
> thought, that rspec is main testing framework for spree. :)

No, it's no true. Pay attention to:
./script/generate extension --help
You have choice, what test stub would be generated.

fry

unread,
Feb 3, 2010, 11:38:49 AM2/3/10
to Spree
It seems like Spree becomes more comfortable for me. Thank you Roman
for your advises!
Reply all
Reply to author
Forward
0 new messages