プロジェクト

全般

プロフィール

Vote #79291

完了

redmine_plugin_controller generates camelcase filename

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
20
version_id:
99
issue_org_id:
28668
author_id:
137958
assigned_to_id:
332
comments:
4
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
139
ステータス-->[Closed]

説明

redmine_plugin_controller generates not snake case file name but camel case file name when specifying controller name as camel case.

For example:

$ bundle exec rails generate redmine_plugin_controller hello_message FooBars
      create  plugins/hello_message/app/controllers/FooBars_controller.rb
      create  plugins/hello_message/app/helpers/FooBars_helper.rb
      create  plugins/hello_message/test/functional/FooBars_controller_test.rb

This causes

On the other hand, redmine_plugin_model generates snake case file name when specifying model name as camel case.

$ bundle exec rails generate redmine_plugin_model hello_message FooBar
      create  plugins/hello_message/app/models/foo_bar.rb
      create  plugins/hello_message/test/unit/foo_bar_test.rb
      create  plugins/hello_message/db/migrate/004_create_foo_bars.rb

Ruby on Rails' @rails generate controller FooBars@ command generates snake case file name: 'foo_bars_controller.rb', too.

Environment is as follows

Environment:
  Redmine version                3.4.5.stable.17297
  Ruby version                   2.4.3-p205 (2017-12-14) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               SQLite
  • trunk has same behavior.

I expect to generate controller file with snake case name even if controller name is specified by camel case, like model file name.


journals

* lib/generators/redmine_plugin_controller/redmine_plugin_controller_generator.rb
uses the argument of controller name to generate file name without modification to snake case.
For example,
<pre>template 'controller.rb.erb', "#{plugin_path}/app/controllers/#{controller}_controller.rb"</pre>
* lib/generators/redmine_plugin_model/redmine_plugin_model_generator.rb
uses the argument of model name to generate file name with modification to snake case.
For example,
<pre>template 'model.rb.erb', "#{plugin_path}/app/models/#{model.underscore}.rb"</pre>

I attached a fix patch for redmine_plugin_controller_generator.rb to generate file name with snake case controller name like redmine_plugin_model_generator.rb.
This patch is generate under svn r17297 (3.4-stable branch).
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
The patch improves the consistency of the behavior of generators. Setting target version to 4.1.0.
--------------------------------------------------------------------------------
Committed. Thank you for your contribution.

FYI: redmine_plugin_model generates snake case filename since r9718.

--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョン4.0.0_99 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0