気づき #864
奈良 裕記 さんが5年以上前に更新
Redmineの運用にて、RAILS Console利用事例の蓄積用チケット
Redmineのパスから下記実行してコマンド入力
bundle exec rails console production
h2. 関連情報
Rubyでメソッド一覧を確認するmethodsメソッドが便利
https://paranishian.hateblo.jp/entry/ruby/methods
h2. RAILS Consoleから使用出来るメソッド一覧
(下記は、Usersクラスのメソッド一覧)
@users = User.new Users.new
pp @users.methods
メソッド名をソートして行単位表示
pp @users.methods.sort
メソッド名で制限して表示
pp @users.methods.grep(/public/)
---
h2. 利用事例
RedmineでRails console実行した設定作業の例
h3. 親子チケットの階層崩れを修正したい
https://redmine.tokyo/issues/725
bundle exec rails console production
irb(main):001:0>Issue.rebuild_tree!
irb(main):001:0>Issue.rebuild_single_tree(1)!
ワンライナー
RAILS_ENV=production bundle exec ruby bin/rails runner 'Issue.rebuild_tree!'
h3. 多数のPJ(階層/名称)に、メンバー登録+ロール設定を一括設定したい
https://redmine.tokyo/issues/723
(リンク先参照、Project(lft/rgt),Member処理含)
h3. プラグインの全PJ一括有効化
https://redmine.tokyo/issues/688
Project.where('identifier like ?', "redmine_tokyo%").each do |project|
project.enable_module!('unofficial_cooking')
end
h3. adminパスワードをコマンドで強制変更
https://redmine.tokyo/issues/702
User.find_by_login('admin').update_attribute(:password, '新パスワード')
quit
ansibleでのインストール時取込例
https://github.com/y503unavailable/redmine-centos-ansible/issues/3
戻る