Spree、Rails 3 和主题
好吧,我一直在尝试按照本教程
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
rails g spree:extention site
创建我自己的扩展名“site”,然后我查看我的 gems 路径,然后在另一个中打开整个 spree-core gem编辑器项目并复制到app/views/layouts/spree_application.html.erb
。如果你的 html 与默认的狂欢商店没有那么不同(我的在 http://daugpigiau.lt 上有很大不同),那么你可能只能使用钩子并覆盖某些部分。我发现了解钩子名称的唯一方法仍然是查看那些我感兴趣的核心宝石和模板。在知道您感兴趣的钩子之后,您可以执行以下操作:
这些只是我自己对我想要更改的地方的部分。
rails destroy spree:extension your_extension_name
,它将恢复在其生成期间执行的所有操作,我一直在努力解决这个问题首先,这部分内容的文档有太多空白,第一次用户无法掌握。
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 theapp/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:
These are just my own partials for the places I wanted to change.
rails destroy spree:extension your_extension_name
and it will revert all the operation that were performed during it's generationI'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.
要更改 Spree 的默认主题,您需要生成自己的扩展并覆盖其中的
spree_core-0.30.1/app/views
中的视图文件。然而,当前版本的 Spree 中存在一个小错误,可能会使主题和扩展创建变得非常混乱。根据文档,要创建一个新扩展,您应该运行以下命令:它应该产生以下输出:
但是,输出是:
行
当前的解决方法是更改 Gemfile 中的
,然后运行
bundle install
和rails 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:And it should produce the following output:
However, the output is:
The current workaround is to change the line
in your Gemfile to
then run
bundle install
andrails 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 inmyext/app/views