New answers tagged


I ended up doing something like this: def clean_duplicated_offers price_params['items'] = price_params['items'].each_with_object([]) do |item, items_array| if items_array.include? item items_array.detect { |i| i == item }['quantity'] += 1 else items_array << item end end end


To produce the set of records only in cars, but not in drivers, you perform a left outer join, then exclude the records you don't want from the right side via a where clause. In Rails 6 you do this in this way: Car.left_outer_joins(:drivers).where(car_drivers: { id: nil }) Take a look at this article: A Visual Explanation of SQL Joins. It may help you ...


def bigcommerce_api_v3_get_customers_by_shop(shop, options = {}) Since you are only extracting a couple values from options here, consider using keyword params instead. It makes it more obvious what specific keys are used by the method, without needing to dig into the method body. raise if params['page'] || params['limit'] # prevent manual pagination ...

Top 50 recent answers are included