【问题标题】:How do I use railties to install files other than migrations (for e.g. config files)如何使用 railties 安装迁移以外的文件(例如配置文件)
【发布时间】:2011-11-26 19:35:52
【问题描述】:

我正在使用 Rails 3.1,并且能够使用 railties 来安装迁移(通过执行 rake railties:install:migrations FROM=plugin_name)。但是,我还需要复制几个配置文件(.yml 等)。 我该怎么做?

【问题讨论】:

    标签: ruby-on-rails rake ruby-on-rails-3.1 ruby-on-rails-plugins rails-engines


    【解决方案1】:

    例如查看我创建的 gem 中的代码:https://github.com/nathanvda/on_the_spot/blob/master/lib/generators/on_the_spot/install/install_generator.rb

    简单地说:使用thor 命令,例如copy_file

    希望这会有所帮助。

    【讨论】:

    • 你如何调用这个特定的任务。我知道我可以通过运行“ruby script/rails g import_products:install”之类的东西来运行整个操作集。但是我如何只运行一个任务,比如“copy_javascripts”?
    • 据我所知,唯一的解决方案是创建不同的生成器。
    猜你喜欢
    • 2011-04-22
    • 2020-04-19
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-26
    相关资源
    最近更新 更多