Questions tagged as 'activerecord'

1
answer

Duda Active Record

I am doing a job for the university they are introducing us in the "Active Record" pattern in C #. The thing is that I have a class called Persistente , let's say the base class from which all the others inherit. It contains methods such a...
asked by 20.03.2018 / 08:08
2
answers

XML API Product FEED

I want to develop a product feed with my suppliers. This is the XML that the API gives me with the available or exhausted products of this distributor to obtain general information about the product but mainly stock, sku, price ... <Item>...
asked by 27.07.2017 / 19:57
1
answer

How to implement a primary key in rails

What is better to use in rails for a composite primary key? Use the composite_primary_keys gem? or use an index that contains the columns that I need for the primary key? What is the best way to uniquely identify a row in a table? , which...
asked by 15.10.2017 / 15:26
1
answer

Update total stock of products

I am trying to create a stock from the new products that are created with the System Purchases. All Compras have a ItemCompra , with a certain product_id and product.quantity , these are nested using a accepts_nested_attribut...
asked by 19.06.2017 / 14:36
1
answer

How to know if a model has 0 relations. Rails

I have a question about how to optimize a query, I'm doing it with a select to an active record query. How could I do this in a single SQL query. Here, for example, is a request. maintenance_service_requests has a Has and belong to many with...
asked by 12.04.2018 / 02:35
1
answer

Update a record in a table and from this create a record in another table

I have a table called products, and when I select a product, it must be deducted from that product from the product table and a record must be created in another table called cart The schema tables are: ActiveRecord :: Schema.define (version:...
asked by 24.06.2017 / 19:12
2
answers

In Ruby on Rails how to insert several records at once with ActiveRecord

I want to do this as if I were doing it in mysql INSERT INTO ratings ('id','app_id','user_id','created_at','updated_at','unique','valoracion','valoracions_id') values (1,2,3,"2017-04-07","2017-04-07",12,4.8,1), (1,2,3,"2017-04-0...
asked by 07.04.2017 / 17:18