Questions tagged as 'active-record'

1
answer

How to prevent a simple query from locking the entire MySQL database

I have an application in Rails that uses a MySQL database with a table with millions of rows. Sometimes it happens that some part of my application does a very heavy query, locking all the rest of the application. How do I prevent these pesky qu...
asked by 13.08.2014 / 02:53
2
answers

Rails and postgres group_by by date considering time zone

How do I group records by date where the field is of type datetime? But that's considering timezone. For example: When the user enters 12/10/2014 23:30:00, it is recorded in the bank 10/13/2014 01:30:00, because our time zone is -2: 00 now...
asked by 08.11.2014 / 13:31
4
answers

Select without the id field (RoR)

I'm having a very silly question, I'm doing a system with Ruby on Rails and I need to do a select where the id field does not come, the problem is that this field is always present, for example: Employee.select('nome, email').all The a...
asked by 19.11.2015 / 15:47
1
answer

What is the best way to add ENUM fields in the Rails 4 model?

I need to reference the numbers in the status field of the database, which are in the form ENUM , with the names of my model . What is the best way to do this? models / item.rb class Item < ActiveRecord::Base # d...
asked by 18.03.2014 / 14:51
1
answer

Attempt to read or write to protected memory

I have an application in C# that connects to the Oracle database. For this the application makes use of NHibernate (a very old version) and Castle ActiveRecord . This has always worked, but now when I try to query the database I...
asked by 27.03.2015 / 12:48
1
answer

Find random objects using conditions

I want to search for example 10 random people of the same party I did the following, but this is selecting people from all parties, what can be done? = D class Pessoa < ActiveRecord::Base class << self def filtra_pessoas(...
asked by 28.09.2016 / 07:17
2
answers

Check if data already exists in the bank with codeigniter

I am starting with codeigniter using the active record to make the conversation with the bank, and wanted to know how do I know if an email already exists in db, would it list all emails and create a foreache doing the verification? Is there a s...
asked by 19.12.2015 / 20:13
3
answers

Select records from a table where the record of a related table is a specific value

I have a table of technical calls and a table of calls. Each 'CALL' has several 'CALLS' and it is in the calls that the field defines the status of the call (Open, Closed, In Progress, Suspended, etc ...) Currently, when I need to list only op...
asked by 24.03.2014 / 15:42
1
answer

How to avoid storing large SELECT memory in Rails?

In the routine I'm developing, I make a simple SELECT in the database, just in a table: Model.select("id").where(:tipo => 2).find_each do |registro| puts registro.id end But this select returns around 160,000 records. Then the system...
asked by 15.12.2017 / 18:51
1
answer

How to change an attribute in the bank via a button

I'm creating a small college project in Ruby on Rails and I came across a problem: I have a table called Person and another call Tools . People have many tools and each tool is owned by one person. I need to add a resource...
asked by 12.06.2016 / 01:36