ruby-on-rails - rails gem : correct place for a controller helper?

标签 ruby-on-rails ruby rubygems

我正在为 Rails 开发一个私有(private) gem,其中包含一个 Controller 助手。

我怀疑这个助手在这两个地方之间:

  • lib/gem_name/my_helper.rb
  • app/controllers/concerns/gem_name/my_helper.rb

它的正确位置是什么?

最佳答案

我认为你应该在 Controller concern中使用它,然后将辅助模块包含到应用程序 Controller 中

所以我更喜欢 app/controllers/concerns/gem_name/my_helper.rb 在 gem 中创建 Controller 助手。

关于ruby-on-rails - rails gem : correct place for a controller helper?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49491152/

相关文章:

ruby-on-rails - 为什么 Passenger/mod_rails 文档要求我显式禁用多 View ?

ruby - 使 Jenkins 'Execute Shell' 与使用 bash shell 时完全相同

ruby-on-rails - NameError:未初始化的常量 ActionController::Dispatcher

ruby-on-rails - 未定义方法 `synchronize' 对于 nil :NilClass

ruby-on-rails - 使用 Rails 和 'paypal-sdk-merchant' gem 将多个接收者添加到 Paypal Mass Pay

mysql - 如何根据列值计算记录之间的小时总和

ruby - 如何将类添加到 HAML 中的条件

json - bundle exec - 你已经激活了 json X,但是你的 Gemfile 需要 json Y

rubygems - 卸载 gem 时出错

ruby-on-rails - Rails respond_with & Rspec Controller : Testing unsuccessful update