[英]Rails-style Rake Tasks for Sinatra (Ruby)
I can't seem to find a gem or example of anyone using Rails-style rake tasks within a Sinatra app. 我似乎找不到在Sinatra应用程序中使用Rails样式的rake任务的任何人的瑰宝或示例。 I would like to clean out my migrations folder and am looking to do something like explained here: When (if) to consolidate ActiveRecord migrations?
我想清理我的迁移文件夹,并希望按照以下说明进行操作: 什么时候合并ActiveRecord迁移?
Sinatra isn't a multi-layer framework in the same way as Ruby on Rails. Sinatra不是与Ruby on Rails相同的多层框架。 Specifically, while you can certainly add a database layer to a Sinatra application, it doesn't support ActiveRecord or Rails migrations "out of the box."
具体来说,尽管您当然可以将数据库层添加到Sinatra应用程序中,但它不支持“开箱即用”的ActiveRecord或Rails迁移。
If you're looking for standard Rails rake tasks and migration support, why not just use Rails? 如果您正在寻找标准的Rails rake任务和迁移支持,为什么不只使用Rails? Sinatra is terrific, but it is not a drop-in replacement for Rails.
Sinatra很棒,但是它并不是Rails的替代品。
If your database connectivity comes from a gem, see if the gem's project has a Rakefile you can re-purpose for your application. 如果您的数据库连接来自gem,请查看gem的项目中是否有Rakefile,您可以将其重新用于您的应用程序。 For example, the sinatra-activerecord gem provides instructions for adding related Rake tasks to your Rakefile.
例如, sinatra-activerecord gem提供了有关将相关Rake任务添加到Rakefile中的说明。
If you rolled your own database connectivity, then you're probably going to have to roll your own Rake tasks as well. 如果您滚动了自己的数据库连接性,那么您可能还必须滚动自己的Rake任务。 The documentation for Rake is extensive, and the features should allow you to automate the tasks you need.
Rake的文档内容丰富,其功能应允许您自动执行所需的任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.