Skip to content

Commit

Permalink
BC rails 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Jan 27, 2010
1 parent cb77bc2 commit 13161b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/ardes/resources_controller/resource_methods.rb
Expand Up @@ -10,22 +10,22 @@ def find_resources

# finds the resource, using the passed id, defaults to the current params[:id]
def find_resource(id = nil)
id ||= respond_to?(:params) && params.present? && params[:id]
id ||= respond_to?(:params) && params.is_a?(Hash) && params[:id]
resource_service.find id
end

# makes a new resource, if attributes are not supplied, determine them from the
# params hash and the current resource_class, or resource_name (the latter left in for BC)
def new_resource(attributes = nil, &block)
if attributes.blank? && respond_to?(:params) && params.present?
if attributes.blank? && respond_to?(:params) && params.is_a?(Hash)
resource_form_name = ActionController::RecordIdentifier.singular_class_name(resource_class)
attributes = params[resource_form_name] || params[resource_name] || {}
end
resource_service.new attributes, &block
end

def destroy_resource(id = nil)
id ||= respond_to?(:params) && params.present? && params[:id]
id ||= respond_to?(:params) && params.is_a?(Hash) && params[:id]
resource_service.destroy id
end
end
Expand Down

0 comments on commit 13161b9

Please sign in to comment.