新 Rails 3.1.3 + Datamapper 路由资产问题
我渴望在新的 Rails 项目中尝试 DataMapper。我使用以下命令创建了我的项目:
rails new project_name -m http://datamapper.org/templates/rails.rb
我决定通过运行来测试我的应用程序:
rails server
当我转到创建的通用主页时,我看不到任何图像。我收到一条错误消息:
ActionController::RoutingError (No route matches [GET] "/assets/rails.png")
如果我创建任何其他脚手架并访问这些页面,我会收到有关未找到样式表或 javascript 的类似错误。我仔细检查以确保常规 Activerecord-rails 应用程序可以正常工作(它确实如此)。我比较疑惑。任何帮助将不胜感激。谢谢 :)
I am eager to try out DataMapper for a new Rails project. I created my project using the following command:
rails new project_name -m http://datamapper.org/templates/rails.rb
I decided to test out my application by running:
rails server
When I go to the generic home page that is created, I can't see any images. I get an error stating:
ActionController::RoutingError (No route matches [GET] "/assets/rails.png")
If I create any other scaffolds and visit those pages, I get similar errors about the stylesheets or javascript not found. I double checked to ensure that a regular Activerecord-rails application worked (which it did). I'm rather puzzled. Any help would be greatly appreciated. Thank you :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于某种原因,DataMapper 的 Rails 模板完全用自己的模板替换了标准的 Gemfile,其中不包含任何资产处理内容(它还删除了一些其他内容,如 jQuery 支持、TestUnit、ActionMailer) ...)。
设置新应用程序后,您需要将这些重新添加到您的
Gemfile
中:根据下面 Frederick 的建议,您还需要将其添加到您的
config/application.rb< /code> 文件:
我打开了一个问题 和 提交了拉取请求来解决此问题。
更新:自 2012 年 1 月 5 日起,此问题现已修复。该模板的行为几乎与标准 Rails 3.1 应用程序相同,唯一的变化是 ActiveRecord 被替换为 DataMapper。 Assets/jQuery 支持现在可以使用。
For some reason, DataMapper's Rails template completely replaces the standard
Gemfile
with their own, which doesn't include any of the asset handling stuff (it also removes a handful of other things like jQuery support, TestUnit, ActionMailer...).You'll want to add these back in to your
Gemfile
after setting up the new application:Per Frederick's suggestion below, you'll also want to add this into your
config/application.rb
file:I opened an Issue and submitted a pull request to fix this.
Update: As of 1/5/2012, this is now fixed. The template behaves nearly identical to a standard Rails 3.1 app with the only change being ActiveRecord being replaced with DataMapper. Assets/jQuery support now works.