【问题标题】:Make Rails App Template CD to root and run bundle commands?将 Rails App Template CD 设为 root 并运行捆绑命令?
【发布时间】:2012-04-09 15:37:59
【问题描述】:

我相信您会欣赏这种懒惰的尝试:我想在 Rails 3.2 中改进我的应用模板脚本。

我会做类似的事情 rails new APPNAME -m path/to/template.rb

我想更新脚本以允许我将cd 加入到新应用程序中,这样我就可以运行bundle exec COMMAND

例如,

if compass = yes?("Would you like to install Compass and Susy?")
gem_group :assets do
 gem 'compass-rails'
 gem 'compass-susy-plugin'
end

     if compass == true
      run "bundle install"
      inside "#{Rails.application.class.parent_name}" do
        run "bundle exec compass install susy"
       end
 end
end

当我运行上面的代码时,我得到一个错误,比如 -

unexpected keyword_do_block (SyntaxError)
  /home/rhodee/GitRepos/dotfiles/workflow.rb:103: syntax error, unexpected keyword_end,   expecting $end

感谢您启用我的懒惰。

【问题讨论】:

    标签: ruby-on-rails ruby thor


    【解决方案1】:

    您应该能够删除“内部”并简单地执行

    run "bundle exec compass install susy"
    

    要真正进入目录并做某事,您可以:

    run "cd #{Rails.application.class.parent_name}/public; rm index.html"
    

    (当然,您可以将上述内容运行为 run "rm public/index.html",但这不是重点。)

    【讨论】:

    • 我要对此投赞成票,因为脚本看起来很糟糕 |指南针安装问题。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 2012-03-17
    相关资源
    最近更新 更多