app/controllers/administrate/application_controller.rb in administrate-0.4.0 vs app/controllers/administrate/application_controller.rb in administrate-0.5.0
- old
+ new
@@ -78,10 +78,21 @@
else
:inactive
end
end
+ helper_method :valid_action?
+ def valid_action?(name, resource = resource_name)
+ !!routes.detect do |controller, action|
+ controller == resource.to_s.pluralize && action == name.to_s
+ end
+ end
+
+ def routes
+ @routes ||= Namespace.new(namespace).routes
+ end
+
def records_per_page
params[:per_page] || 20
end
def order
@@ -99,14 +110,10 @@
def find_resource(param)
resource_class.find(param)
end
def resource_params
- params.require(resource_name).permit(*permitted_attributes)
- end
-
- def permitted_attributes
- dashboard.permitted_attributes
+ params.require(resource_name).permit(dashboard.permitted_attributes)
end
delegate :resource_class, :resource_name, :namespace, to: :resource_resolver
helper_method :namespace
helper_method :resource_name