gpt4 book ai didi

ruby-on-rails - 主动管理自定义

转载 作者:行者123 更新时间:2023-12-03 21:00:31 25 4
gpt4 key购买 nike

我有一个 Event带有字段状态的模型,它是字符串,因此显示为 text_field .但是我有一个可能的状态列表,我想将它显示为 select盒子。另外,当我选择 cancel一个事件的状态,它应该问我取消原因。我无法为此找到好的教程。

最佳答案

以下是几乎所有自定义的示例:)

ActiveAdmin.register Event do
#Menu display index
menu :priority => 1

#Scopes
scope :all
scope :pending
scope :approved
scope :rejected
scope :cancelled
scope :featured

#Filters
filter :city
filter :user, :content_columns => :first_name
filter :name
filter :featured
filter :location
filter :details
filter :start_datetime
filter :end_datetime

# New/Edit forms
form do |f|
f.inputs do
f.input :status, :label => "Event Status", :as => :select, :collection => Event::EVENT_STATUSES
# Conditional show/hide using js
cancel_reason_style = f.object.cancelled? ? "display:block" : "display:none"
reject_reason_style = f.object.rejected? ? "display:block" : "display:none"
f.input :reject_reason, :wrapper_html => {:style => reject_reason_style}, :hint => "Required if status event rejected"
f.input :cancel_reason, :wrapper_html => {:style => cancel_reason_style}, :hint => "Required if status event rejected"
f.input :city, :label => "Event Status"
f.input :name, :label => "Name"
f.input :image, :as => :file, :hint => f.template.image_tag(f.object.image.url(:medium))
f.input :details, :input_html => { :class => 'autogrow', :rows => 5, :cols => 30, :maxlength => 10 }
f.input :start_datetime
f.input :end_datetime
f.input :location, :input_html => { :class => 'autogrow', :rows => 5, :cols => 30, :maxlength => 10 }
f.input :gmap_lattitude
f.input :gmap_logitude
f.input :email
f.input :mobile
f.input :website
end
f.buttons
end

index do
column :name
column :user
column :city
column :status
column :start_datetime
# column :end_datetime
column :email
default_actions
end

show do |event|
attributes_table do
row :name
row :details
row :user
row :city
row :status do event.status.titleize end
# has_many :through
row :themes do
event.themes.collect{|t| t.name}.join(', ')
end
row :event_type do
event.event_types.collect{|t| t.name}.join(', ')
end
row :start_datetime
row :end_datetime
row :location
row :gmap_lattitude
row :gmap_logitude
row :email
row :mobile
row :created_at
row :updated_at

end
active_admin_comments
end

end

编辑
有几个主题可用

https://github.com/vigetlabs/active_material

https://github.com/activeadmin-plugins/active_admin_theme

https://github.com/paladini/activeadmin-themes

关于ruby-on-rails - 主动管理自定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8310926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com