Rails 管理员 - 无法自定义新操作而不是在应用操作中显示
Rails Admin - Can not customize a new action instead of show in app action
我已经按照这个 tutorial 创建了一个新的 rails admin action
。
1.create lib 文件夹中的文件 name in_app_show.rb
:
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdmin
module Config
module Actions
class InAppShow < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :member do
true
end
register_instance_option :visible? do
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
end
register_instance_option :controller do
proc do
redirect_to main_app.url_for(@object)
end
end
register_instance_option :link_icon do
'icon-camera-retro'
end
register_instance_option :pjax? do
false
end
end
end
end
end
2.In rails_admin.rb
我按照你看到的做了:
require Rails.root.join('lib','in_app_show.rb')
RailsAdmin::Config::Actions.register(RailsAdmin::Config::Actions::InAppShow)
RailsAdmin.config do |config|
....
end
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
# show_in_app
in_app_show
end
但是图标和动作都没有转up.As你可以看到here没有与show_in_app.rb
相关的文件。我认为在最新版本rails admin 不再 show in app action!
你能帮我做这样的动作吗?
非常感谢
我使用您的代码构建了一个应用程序。我想问题是你重定向了你的路径。这是我的代码:
``````
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdmin
module Config
module Actions
class InAppShow < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :member do
true
end
register_instance_option :visible? do
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
end
register_instance_option :controller do
proc do
flash[:notice] = "Your customized action #{@action}"
respond_to do |format|
format.html { render file: "#{Rails.root}/app/views/in_app_show" }
end
end
end
register_instance_option :link_icon do
'icon-camera-retro'
end
register_instance_option :pjax? do
false
end
end
end
end
end
我已经按照这个 tutorial 创建了一个新的 rails admin action
。
1.create lib 文件夹中的文件 name in_app_show.rb
:
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdmin
module Config
module Actions
class InAppShow < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :member do
true
end
register_instance_option :visible? do
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
end
register_instance_option :controller do
proc do
redirect_to main_app.url_for(@object)
end
end
register_instance_option :link_icon do
'icon-camera-retro'
end
register_instance_option :pjax? do
false
end
end
end
end
end
2.In rails_admin.rb
我按照你看到的做了:
require Rails.root.join('lib','in_app_show.rb')
RailsAdmin::Config::Actions.register(RailsAdmin::Config::Actions::InAppShow)
RailsAdmin.config do |config|
....
end
config.actions do
dashboard # mandatory
index # mandatory
new
export
bulk_delete
show
edit
delete
# show_in_app
in_app_show
end
但是图标和动作都没有转up.As你可以看到here没有与show_in_app.rb
相关的文件。我认为在最新版本rails admin 不再 show in app action!
你能帮我做这样的动作吗?
非常感谢
我使用您的代码构建了一个应用程序。我想问题是你重定向了你的路径。这是我的代码: ``````
require 'rails_admin/config/actions'
require 'rails_admin/config/actions/base'
module RailsAdmin
module Config
module Actions
class InAppShow < RailsAdmin::Config::Actions::Base
RailsAdmin::Config::Actions.register(self)
register_instance_option :member do
true
end
register_instance_option :visible? do
authorized? && (bindings[:controller].main_app.url_for(bindings[:object]) rescue false)
end
register_instance_option :controller do
proc do
flash[:notice] = "Your customized action #{@action}"
respond_to do |format|
format.html { render file: "#{Rails.root}/app/views/in_app_show" }
end
end
end
register_instance_option :link_icon do
'icon-camera-retro'
end
register_instance_option :pjax? do
false
end
end
end
end
end