Skip to content

Instantly share code, notes, and snippets.

@kneipp
Created December 5, 2012 23:59
Show Gist options
  • Save kneipp/4220683 to your computer and use it in GitHub Desktop.
Save kneipp/4220683 to your computer and use it in GitHub Desktop.
formtastic
# encoding: UTF-8
ActiveAdmin.register Task do
scope :all, :default => true
scope :desta_semana do |tasks|
tasks.where('final_date >= ? and final_date < ?', -1.day.from_now, 1.week.from_now)
end
scope :atrasadas do |tasks|
tasks.where('final_date < ? and is_done = ?', -1.day.from_now, false)
end
scope :minhas do |tasks|
tasks.where(:admin_user_id => current_admin_user.id)
end
index do
column :title
column { |task| status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) }
column :final_date
default_actions
end
#New/Edit forms
form html: { enctype: "multipart/form-data" } do |f|
f.inputs "Detalhes da Tarefa" do
f.input :project
f.input :admin_user # puts <AdminUser:0x007fef37e6a518>
f.input :title
f.input :description
f.input :is_done
f.input :final_date
end
f.buttons
end
show do
panel "Detalhes da Tarefa" do
attributes_table_for task do
row("Status") { status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) }
row("Título") { task.title }
row("Projeto") { link_to task.project.title, admin_project_path(task.project) }
row("Responsável") { link_to task.admin_user.email, admin_admin_user_path(task.admin_user) }
row("Prazo") { task.final_date? ? l(task.final_date, :format => :long) : '-' }
end
end
active_admin_comments
end
sidebar "Outras Tarefas Desse Usuário", :only => :show do
table_for current_admin_user.tasks.where(:project_id => task.project) do |t|
t.column("Status") { |task| status_tag (task.is_done ? "OK" : "Pendente"), (task.is_done ? :ok : :error) }
t.column("Título") { |task| link_to task.title, admin_task_path(task) }
end
end
end
@kneipp
Copy link
Author

kneipp commented Dec 6, 2012

RT @synt4x: @kneipp try something like what's written here: http://github.com/justinfrench/f… (the :member_label part)

@kneipp
Copy link
Author

kneipp commented Dec 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment