Forked from marinalohova/rails_admin_approve_review.rb
Created
January 20, 2017 06:38
-
-
Save Longpc/dad71b62d91c5f8085e30293c1676311 to your computer and use it in GitHub Desktop.
Custom action for RailsAdmin
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
require 'rails_admin/config/actions' | |
require 'rails_admin/config/actions/base' | |
module RailsAdminApproveReview | |
end | |
module RailsAdmin | |
module Config | |
module Actions | |
class ApproveReview < RailsAdmin::Config::Actions::Base | |
register_instance_option :visible? do | |
authorized? && !bindings[:object].approved | |
end | |
register_instance_option :member do | |
true | |
end | |
register_instance_option :link_icon do | |
'icon-check' | |
end | |
register_instance_option :controller do | |
Proc.new do | |
@object.update_attribute(:approved, true) | |
flash[:notice] = "You have approved the review titled: #{@object.title}." | |
redirect_to back_or_index | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment