On Github tristanoneil / activeadmin-presentation
class PostsController < ApplicationController
def update
@post = Post.find(params[:id])
@post.update_attributes(params[:post])
end
end
class PagesController < ApplicationController
def update
@page = Page.find(params[:id])
@page.update_attributes(params[:page])
end
end
<%= form_for(@post) do |f| %>
<%= f.text_field :title %>
<%= f.text_area :body %>
<%= f.submit %>
<% end %>
<%= form_for(@page) do |f| %>
<%= f.text_field :title %>
<%= f.text_area :body %>
<%= f.submit %>
<% end %>
ActiveAdmin.register Post do end ActiveAdmin.register Page do end
gem 'activeadmin'
rails generate active_admin:install rails generate active_admin:resource [resource]
index do
column :title
column :author
default_actions
end
index do
column :title
if can? :manage, Post
column :some_secret_data
end
end
show do
h3 post.title
div do
markdown post.body
end
panel "Comments" do
table_for(workshop.comments) do
column :name
column :email
end
end
end
form do |f|
f.inputs "Post Details" do
f.input :title
f.input :author, :as => :select, :collection => ["Tristan O'Neil"]
f.input :created_at, :ampm => true
f.input :body
end
f.buttons
end
controller do
def update
# override default update action behavior.
end
end