Module: Cathode::Action::RequiresHasOneAssociation

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_one` 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 ‘:resource` (`has_one`)



157
158
159
# File 'lib/cathode/action.rb', line 157

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

#error_messageObject

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



162
163
164
# File 'lib/cathode/action.rb', line 162

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