Skip to content

Instantly share code, notes, and snippets.

@jorgeacaballero
Created July 8, 2015 01:43
Show Gist options
  • Save jorgeacaballero/0418998d0f9d6b040364 to your computer and use it in GitHub Desktop.
Save jorgeacaballero/0418998d0f9d6b040364 to your computer and use it in GitHub Desktop.
ActiveAdmin.register Estate, as: "Inmueble", namespace: :provider do
permit_params :name, :price, :kind, :ground_area, :max_period, :common_area, :special_attr, :max_down, :room_number, :capital_gain, :ground_unit, :special_offer, :construction_unit, :construction_area, :city, :address, :gposition, :description, :sold, :new, :project_id, :real_estate_id, images_attributes: [:description, :picture, :id]
scope("All") { |scope| scope.where(real_estate_id: current_provider_user.real_estate_id) } #, default: true
before_build do |record|
record.real_estate_id = current_provider_user.real_estate_id
record.visible = false
end
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Estate", :multipart => true do
f.input :name, label: 'Nombre'
f.input :price, label: 'Precio'
f.input :kind, label: 'Tipo', as: :select, collection: ["Apartamento", "Bodega", "Casa", "Casa de Campo", "Casa de Playa", "Local Comercial", "Lote Comercial", "Lote Residencial", "Oficina", "Townhouse/Villa"]
f.input :ground_area, label: 'Area Terreno'
f.input :ground_unit, label: 'Medida de Area Terreno', as: :select, collection: ["Mts2", "Vrs2"]
f.input :construction_area, label: 'Area de Construcción'
f.input :construction_unit, label: 'Medida de Area de Const.', as: :select, collection: ["Mts2", "Vrs2"]
f.input :city, label: 'Ciudad', as: :select, collection: ["Choloma", "Choluteca", "Comayagua", "Comayaguela", "Danlí", "Progreso", "Juticalpa", "La Ceiba", "La Lima", "Puerto Cortés", "Roatan", "San Pedro Sula", "Santa Lucía", "Santa Rosa de Copán", "Siguatepeque", "Tegucigalpa", "Tela", "Villanueva"]
f.input :address, label: 'Dirección'
f.input :gposition, label: 'Posición GPS'
f.input :special_offer, label: 'Oferta Especial'
f.input :capital_gain, label: 'Plusvalía'
f.input :room_number, label: 'No. de Cuartos'
f.input :max_down, label: 'Prima Máxima (%)'
f.input :max_period, label: 'Plazo Máximo (%)'
f.input :special_attr, label: 'Atributos Destacados'
f.input :common_area, label: 'Áreas Comunes'
f.input :sold, label: 'Vendido?'
f.input :new, label: 'Nuevo?'
f.input :project, label: 'Proyecto Certificado'
f.input :description, as: :html_editor, label: 'Descripción'
f.inputs do
f.has_many :images, heading: 'Slider' do |photo|
photo.input :description
photo.input :picture
photo.input :_destroy, :as=>:boolean, :required => false, :label=>'Borrar'
end
end
end
f.actions
end
show :title => :name do |estate|
attributes_table do
rows :name, :price, :kind, :ground_area, :city, :address, :gposition, :description, :sold, :new, :project, :real_estate
row "Slider" do
ul do
estate.images.each do |img|
li do
image_tag img.picture.url(:thumb)
end
end
end
end
end
end
index do
selectable_column
column :id
column :name
column :price
column :city
column :sold
column :new
column :project
column :real_estate
actions
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment