Created
January 10, 2013 16:59
-
-
Save diatmpravin/4503766 to your computer and use it in GitHub Desktop.
active-admin-sample-form-index-show for nested form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register Bar do | |
# controller.load_and_authorize_resource | |
controller do | |
load_and_authorize_resource :except => [:update, :index, :show, :edit] | |
def scoped_collection | |
end_of_association_chain.accessible_by(current_ability) | |
end | |
end | |
form(:html => { :multipart => true }) do |f| | |
f.inputs "Enter bar details" do | |
f.input :admin_user_id, :as => :select, :collection => AdminUser.all.map {|u| [u.name,u.id]}, :include_blank => true | |
f.input :name | |
f.input :short_name | |
f.input :country | |
f.input :state | |
f.input :address | |
f.input :phone | |
f.input :fax | |
f.input :email | |
f.inputs "Weblinks of bar" do | |
f.has_many :weblinks do |y| | |
y.input :weblink_name | |
y.input :weblink_url | |
end | |
end | |
f.inputs "Images of bar" do | |
f.has_many :galleries do |g| | |
g.input :image, :as => 'file' | |
end | |
end | |
end | |
f.buttons | |
end | |
index do | |
column :admin_user_id | |
column :name | |
column :short_name | |
column :country | |
column :state | |
column :address | |
column :phone | |
column :fax | |
column :email | |
default_actions | |
end | |
show do |bar| | |
panel "Bar details" do | |
attributes_table_for bar, :admin_user_id, :country, :state, :address, :email, :fax, :name, :phone, :short_name | |
end | |
panel("Weblinks") do | |
table_for(bar.weblinks) do | |
column "Weblink Name" do |weblinks| | |
weblinks.weblink_name | |
end | |
column "Weblink Url" do |weblinks| | |
weblinks.weblink_url | |
end | |
end | |
end | |
panel("Images") do | |
table_for(bar.galleries) do | |
column "Image" do |galleries| | |
image_tag(galleries.image, :height => '200', :width => '200') | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment