问题标签 [rake-task]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
ruby-on-rails - 生产中的Rails未初始化常量
我有一个奇怪的问题。在开发中此问题不存在,但在生产中 rake 向我抛出此错误消息“未初始化的常量程序”
“程序”是一个活动记录模型,它就在那里,它在模式文件中,它在 app/model 文件夹中。
我像这样执行它 rake import:xml RAILS_ENV=production. 可能是什么问题呢?下面是完整的堆栈跟踪
第 18 行:program = Program.find(:first, :conditions => ['programident = ?', broadcast['PROGRAMME']['PROGRAMME_ID']])
ruby-on-rails - Rails - 帮助完成 rake 任务
我有一个需要运行的 rake 任务,以便清理(删除正斜杠)数据库中的一些数据。这是任务:
这让我可以跑步rake db:substitute_slashes --trace
如果我puts c.permalink
在 gsub 之后做!我可以看到它正在正确设置属性。不过救命!似乎没有工作,因为数据没有改变。有人可以发现问题可能是什么吗?
另一件事,我安装了回形针,这个任务正在触发[paperclip] Saving attachments.
,我宁愿避免。
ruby-on-rails - 通过 Ruby (ROR) 导入 MongoDb 集合
我正在尝试使用通过 mongoexport 工具导出的集合来播种我的数据库,但我似乎找不到任何通过 Ruby 使用 mongoimport 工具的方法。
我查看了Mongo 驱动程序以了解如何通过 Ruby 执行 mongo 查询,并考虑从导出中迭代 json 的每一行,但是有像“$oid”这样的键在尝试执行 collection.insert() 时会出错
是否可以在 Ruby 中使用 mongoimport 工具,或者将代码添加到 seed.rb 以便导入 mongo 集合的最佳方法是什么?
ruby-on-rails - rails 3 内置 rake 任务,它们在哪里?
我可以将我的自定义 rake 任务放入lib/tasks/
,但内置任务(即 db:migrate、db:seed 等)存储在哪里?
我看了看:[INSTALLATION_DIRECTORY]/gems/rails-[VERSION]/lib/tasks
但找不到那条路。也许我使用 RVM 很重要?
我想检查他们的来源以获得一些灵感。
ruby-on-rails - 具有不同模式的多个数据库的 Rake 任务
我正在开发一个多数据库 Rails 3 应用程序。每个数据库都有不同的模式(并且在生产中位于不同的位置)。我已将应用程序设置为与不同的数据库对话,如下所示:
数据库.yml
模型/other_base.rb
模型/some_model.rb
现在,这适用于 web 应用程序,但不适用于运行 rake 任务,包括测试(未正确加载夹具)。有没有可用的宝石?任何帮助表示赞赏。
此外,最好创建一个 schema.rb 文件,该文件可以处理不同数据库的不同模式 - 也就是说,将允许我执行 rake db:create 或 db:setup 之类的操作,并让它使用数据库创建多个数据库- 特定模式。
ant - 命令显示 rakefile 任务的所有描述?
我知道在 Ant / Nant 中,您可以通过 -projecthelp 之类的参数来获取带有描述的可用目标列表。
对于 rakefile 的任务,是否有类似的命令行参数?
还有一种方法可以从 rakefile 本身生成文档吗?
ruby-on-rails - Rails Rake Task - Access to model class
I would like to define a Ruby (1.9.2)-on-Rails(3.0.5) rake task which adds a user to the User table. The file looks like this:
I would then invoke the task as
I tested the code in the :adduser task in the Rails console, and it works fine. I tested the rake task, running only
in the body of the task, and it worked fine.
However, when I combined them, it complained, saying
I tried a
at above the namespace definition in the rake file, but that didn't work. I got
What do I need to do so that I have the same access to the User model class in the Rake task that I have in the Rails console?
ruby-on-rails - 如何构建任务'db:populate'
我目前在 lib/tasks/sample_data.rb 中有这个 rake 任务
运行时rake db:populate
出现错误,Don't know how to build task 'db:populate'
. 我该如何解决这个问题?
注意:我是 Rails/Ruby 的新手。我正在使用 Rails 3。
ruby-on-rails-3 - 如何使用 Rake 为 Rails 项目创建目录结构
我有一个需要创建一些目录的 Rails 3 应用程序。我想要一个 rake 任务,我可以运行它作为一种初始化过程来执行此操作。基本上我想做: rake app:create_dirs
或类似的事情。我尝试使用“目录”命令,但它们似乎仅用于 rake 中的依赖项。任何想法如何很好地做到这一点?我的目录结构需要如下所示:
在哪里和n
是0..9
m
0..9
感谢您的任何建议。
deployment - 无法从 rake 任务运行 heroku pg:info
我正在编写一个 rake 任务以部署在 heroku 上。该任务只有一步:
sh %{ heroku pg:info --app myapp}
它失败了
heroku pg:info 未知命令。运行“heroku help”以获取使用信息。耙中止!命令失败,状态为 (1):[heroku pg:info --app...]
有趣的是,任何其他 heroku 命令似乎都可以工作。只是“heroku pg”不起作用。
想法?
提前感谢您的帮助