Module: Cathode::Action::RequiresHasManyAssociation

Includes:
RequiresAssociation
Defined in:
lib/cathode/action.rb

Overview

Raises an error if the action was defined on a resource whose parent doesn’t have a ‘has_many` association to the resource

Instance Method Summary collapse

Methods included from RequiresAssociation

#after_resource_initialized

Instance Method Details

#association_keysObject

Defines the possible associations as ‘:resources` (`has_many`).



173
174
175
# File 'lib/cathode/action.rb', line 173

def association_keys
  [resource.name.to_s.pluralize.to_sym]
end

#error_messageObject

Provides an error message to display if the association is missing.



178
179
180
# File 'lib/cathode/action.rb', line 178

def error_message
  "Can't use default :#{name} action on `#{parent.name}' without a has_many or has_and_belongs_to_many `#{resource.name.to_s.singularize}' association"
end