Rails Adminを使用していますが、モデルの作成および更新アクションの後にリダイレクトをカスタマイズしたいと思います。
新しいプラグインを作成し、バックエンドで設定しました。タブをクリックすると、表示ページに移動します。私がやりたいのは、編集を書き直して、保存/更新後にこのページにリダイレクトするアクションを作成することです。
私はグーグルで検索しましたが、何らかの理由で、私が試したすべてがうまくいきません。どんな洞察も歓迎します。
ありがとうございました。
=====
その後、切り抜きページにリダイレクトしようとしています。そのコードをどこに置くかわかりません。以下のRailsAdminCropモジュールに入れますか?もしそうなら、どのように?ドキュメントにはこれについては記載されていません。
構成:
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
require "rails_admin_crop/engine"
module RailsAdminCrop
end
module RailsAdmin
module Config
module Actions
class Crop < RailsAdmin::Config::Actions::Base
register_instance_option :member do
true
end
register_instance_option :link_icon do
'icon-th-large'
end
register_instance_option :controller do
Proc.new do
flash.now[:notice] = ": #{@object.title}."
end
end
end
end
end
end
または、ブロックを編集アクションに渡して、それをrails_admin.rb初期化子に入れますか?もしそうなら、私はどのような構成をしますか?
module RailsAdmin
module Config
module Actions
class Crop < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
end
end
end
end
config.actions do
dashboard
index
new
crop
show
edit
delete
end
レーキルートの後(これはデフォルトルートです):
Routes for RailsAdmin::Engine:
dashboard GET / rails_admin/main#dashboard
index GET|POST /:model_name(.:format) rails_admin/main#index
new GET|POST /:model_name/new(.:format) rails_admin/main#new
export GET|POST /:model_name/export(.:format) rails_admin/main#export
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
history_index GET /:model_name/history(.:format) rails_admin/main#history_index
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
show GET /:model_name/:id(.:format) rails_admin/main#show
edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
history_show GET /:model_name/:id/history(.:format) rails_admin/main#history_show
show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app