Spree、Rails 3 和主题

发布于 2024-09-27 23:54:44 字数 373 浏览 4 评论 0原文

好吧,我一直在尝试按照本教程

http://blog.endpoint.com/2010/01/rails-ecommerce-spree-hooks-tutorial.html

但是主页根本没有改变,因为教程的意思是对于 Rails 2,我只是想知道我需要对教程进行哪些更改才能使其与 Rails 3 兼容?

比使用钩子更简单的解决方案受到欢迎。另外,当我这样做时,有没有办法撤消您在 Rails 中运行的命令,例如卸载扩展。

Well, I've been trying to change the default theme of spree by following this tutorial

http://blog.endpoint.com/2010/01/rails-ecommerce-spree-hooks-tutorial.html

But the homepage doesn't change at all, well since the tutorial is meant for rails 2, I'm just wondering what do I need to change from the tutorial to make it work with rails 3?

Simpler solution than using hooks is welcomed. Also while I'm at it, is there a way to undo the command you run in rails like maybe uninstalling an extension.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

川水往事 2024-10-04 23:54:44
  1. 对我有用的解决方案是使用 rails g spree:extention site 创建我自己的扩展名“site”,然后我查看我的 gems 路径,然后在另一个中打开整个 spree-core gem编辑器项目并复制到 app/views/layouts/spree_application.html.erb

如果你的 html 与默认的狂欢商店没有那么不同(我的在 http://daugpigiau.lt 上有很大不同),那么你可能只能使用钩子并覆盖某些部分。我发现了解钩子名称的唯一方法仍然是查看那些我感兴趣的核心宝石和模板。在知道您感兴趣的钩子之后,您可以执行以下操作:

class PigiauHooks < Spree::ThemeSupport::HookListener
  # custom hooks go here
  insert_after :admin_inside_head, 'shared/admin/ckeditor_include'
  insert_before :admin_product_form_meta, 'shared/admin/product_editor'
  insert_before :admin_product_form_additional_fields, 'shared/admin/unavailable_on'
end

这些只是我自己对我想要更改的地方的部分。

  1. 是的,您可以撤消扩展生成部分,就像任何其他生成一样,您只需要运行 rails destroy spree:extension your_extension_name ,它将恢复在其生成期间执行的所有操作,

我一直在努力解决这个问题首先,这部分内容的文档有太多空白,第一次用户无法掌握。

  1. The solution that worked for me was to create my own extension say 'site' with rails g spree:extention site then I've look at my gems path and just opened the whole spree-core gem in another editor project and copied over the app/views/layouts/spree_application.html.erb.

If your html is not that different (mine is quite different at http://daugpigiau.lt) from default spree shop you might be able to only use hooks and override some of the parts. Still the only way I've found to know hook names was to look inside those spree core gems and templates that were interesting for me. After you know what hooks are of interest to you you can do something like:

class PigiauHooks < Spree::ThemeSupport::HookListener
  # custom hooks go here
  insert_after :admin_inside_head, 'shared/admin/ckeditor_include'
  insert_before :admin_product_form_meta, 'shared/admin/product_editor'
  insert_before :admin_product_form_additional_fields, 'shared/admin/unavailable_on'
end

These are just my own partials for the places I wanted to change.

  1. Yes you can undo the extension generation part as any other generation you just need to run rails destroy spree:extension your_extension_name and it will revert all the operation that were performed during it's generation

I've strugled with the overriding part at first cause documentation on this one has a bit too much blank spaces for the first time user to grasp.

一张白纸 2024-10-04 23:54:44

要更改 Spree 的默认主题,您需要生成自己的扩展并覆盖其中的 spree_core-0.30.1/app/views 中的视图文件。然而,当前版本的 Spree 中存在一个小错误,可能会使主题和扩展创建变得非常混乱。根据文档,要创建一个新扩展,您应该运行以下命令:

$ rails g spree:extension myext

它应该产生以下输出:

 create  myext
 create  myext/db
 create  myext/public
 create  myext/LICENSE
 create  myext/Rakefile
 create  myext/README.md
 create  myext/.gitignore
 create  myext/myext.gemspec
 create  myext/lib/tasks/install.rake
 create  myext/app
 create  myext/app/controllers
 create  myext/app/helpers
 create  myext/app/models
 create  myext/app/views
 create  myext/spec
  exist  myext/lib
 create  myext/lib/myext_hooks.rb
 create  myext/lib/tasks/myext.rake
 create  myext/lib/myext.rb
 create  myext/spec/spec_helper.rb
gemfile  myext

但是,输出是:

create  myext
create  myext/config
create  myext/db
create  myext/public
create  myext/LICENSE
create  myext/Rakefile
create  myext/README.md
Could not find ".gitignore" in any of your source paths. Your current source paths are:

gem 'spree'

当前的解决方法是更改​​ Gemfile 中的

gem 'spree', :git => "git://github.com/railsdog/spree.git", :tag => "v0.30.1"

,然后运行 ​​bundle installrails g spree:extension myext
再次。它将正确创建所有文件并将其插入到您的 Gemfile 中。然后您可以覆盖 myext/app/views 中的所有必需文件

To change the default theme of Spree you need to generate your own extension and override the view files from spree_core-0.30.1/app/views in it. However, there's a little bug in the current version of Spree that can make theming and extension creation really confusing. According to the docs, to create a new extension you should run the following command:

$ rails g spree:extension myext

And it should produce the following output:

 create  myext
 create  myext/db
 create  myext/public
 create  myext/LICENSE
 create  myext/Rakefile
 create  myext/README.md
 create  myext/.gitignore
 create  myext/myext.gemspec
 create  myext/lib/tasks/install.rake
 create  myext/app
 create  myext/app/controllers
 create  myext/app/helpers
 create  myext/app/models
 create  myext/app/views
 create  myext/spec
  exist  myext/lib
 create  myext/lib/myext_hooks.rb
 create  myext/lib/tasks/myext.rake
 create  myext/lib/myext.rb
 create  myext/spec/spec_helper.rb
gemfile  myext

However, the output is:

create  myext
create  myext/config
create  myext/db
create  myext/public
create  myext/LICENSE
create  myext/Rakefile
create  myext/README.md
Could not find ".gitignore" in any of your source paths. Your current source paths are:

The current workaround is to change the line

gem 'spree'

in your Gemfile to

gem 'spree', :git => "git://github.com/railsdog/spree.git", :tag => "v0.30.1"

then run bundle install and rails g spree:extension myext
again. It will create all the files correctly and plug it into your Gemfile. Then you can override all the necessary files in myext/app/views

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文