Skip to content

Instantly share code, notes, and snippets.

@gudata
Forked from sanaumair/boatshop resultitem class
Created March 20, 2012 15:31
Show Gist options
  • Save gudata/2137074 to your computer and use it in GitHub Desktop.
Save gudata/2137074 to your computer and use it in GitHub Desktop.
def validate params
raise OURERROR if !(self.manufacturer == params[:manufacturer] and self.country_code and params[:country_code] and self.model == params[:model])
end
def show
query_builder = ::Factory::query_builder
api_response_hash = query_builder.get_item(params[:id], params[:item_type])
raise ActionController::RoutingError.new 'Not Found' if api_response_hash[:items].blank?
@result_item = ::Factory.create_result_item(api_response_hash['items'][0])
@result_item.validate params
add_breadcrumb({
:link => result_items_url(:search => @search.to_hash),
:title => @result_item.breadcrumb_title,
:name => @result_item.breadcrumb_title,
})
initialize_prev_next_items unless @search.new_object
initialize_lead @result_item
rescue OURERROR
redirect_to :internal_server_error_errors
end
end
@gudata
Copy link
Author

gudata commented Mar 20, 2012

OURERROR check models/api/errors and make your own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment