This file contains 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
module ActiveAdmin | |
module Inputs | |
class FilterNumericRangeInput < ::Formtastic::Inputs::StringInput | |
include FilterBase | |
def to_html | |
input_wrapping do | |
[ label_html, | |
builder.text_field(gt_input_name, input_html_options(gt_input_name)), | |
template.content_tag(:span, "-", :class => "seperator"), |
This file contains 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
# Add Action button on the top navigation menu. Useful for resource with nested resources | |
action_item :only => :show do | |
link_to('Show Users', admin_group_users_path(resource)) | |
end | |
# Custom show page with children items | |
show do |
This file contains 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
class ApplicationController < ActionController::API | |
include AbstractController::Translation | |
include ActionController::MimeResponds | |
include ActionController::ImplicitRender | |
include ActionController::StrongParameters | |
# Gems that tries to include something in ActionController::Base | |
include JSend::Rails::Controller | |
include CanCan::ControllerAdditions |
This file contains 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
class Ability | |
include CanCan::Ability | |
attr_reader :current_user | |
def initialize(user) | |
alias_action :create, :update, :destroy, :to => :write | |
@current_user = user || User.new |
This file contains 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
# Add this code to a new file and you can put it under app/admin/lib folder or else config/initializer/actice_admin.rb | |
module ActiveAdmin | |
module Views | |
class TableFor | |
def html_column(attribute) | |
column(attribute){ |model| model[attribute].html_safe } | |
end | |
def bool_column(attribute) |
This file contains 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
# config/initializers/active_admin.rb | |
ActiveAdmin.setup do |config| | |
config.current_user_method = :current_user | |
config.authentication_method = :authenticate_user! | |
config.before_filter :admin_role_filter | |
end | |
# Adding all recource names to Permissions table after ActiveAdmin is loaded |
This file contains 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 AdvocacyPage do | |
menu label: 'Advocacy Page', url: "/admin/advocacy_pages/edit" | |
breadcrumb { [] } | |
permit_params :heading, :description | |
actions :update | |
controller do | |
def resource |
This file contains 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
gem 'active_model_serializers' | |
gem 'activeadmin' | |
gem 'jquery-ui-rails' |
This file contains 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 Product do | |
# Will show the default main content... | |
show do | |
# Do stuff before | |
default_main_content | |
# Do stuff after | |
end | |
# ... Or if you want to customize further |
This file contains 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 Article do | |
index do | |
selectable_column | |
id_column | |
column :name, :sortable => :name do |resource| | |
editable_text_column resource, :name | |
end | |
column 'Type', :sortable => :article_type do |resource| | |
column_select(resource, :article_type, ["News", "Story", "Case Study", "Business"]) | |
end |