rails-activerecord tag

33 questions


1 answers
89 views
0
To Search Rails by Has_many through Model Criteria

Some models have the following relationships:Group-<GroupUser>-UserUser can belong to Group.How should I write to find Group to which User A and User B and User COnly belong?Now I'm checking the...


3 answers
95 views
0
Methods for deleting data from columns in rails

Does Rails (ActiveRecord) have a method to delete the contents of a specific column?When I searched, I couldn't find the information to delete the column itself.If I don't have it, I'll try to impleme...


1 answers
83 views
0
How do I use elements of a record as wildcards when searching find_by?

Is there a way to make an element of a record that is rails recognized as a wildcard or to implement something similar?There is a post model that shows the article you posted.The post contains the aut...


2 answers
104 views
0
The order of records (id) in the table will be changed after bulk update in the Rails app's Activerecord.

We have made a new registration as follows.After that, I pressed the Edit button to change the product name from Product B to Hogehoge.2 Stainless Steel BF-078 10K 350A 3P 2,000 3,000 4,000 9,0002 Sta...


1 answers
102 views
0
Hierarchical Model Form Does Not Appear

We are currently creating forms for models in hierarchical relationships.Below is the model file.post.rb has_many:itemsaccepts_nested_attributes_for —itemsitem.rb has_one:heading, dependent::destroyha...


1 answers
84 views
0
MySQL collate utf8_unicode_ci does not match Suzuki

I use Rails 3.2.13+MySQL5.Collation in MySQL is collate utf8_unicode_ci.I didn't know this function existed, so I was surprised that I searched and matched the data in full-width katakana in full-widt...


1 answers
84 views
0
What's the difference between what appears as Load and what doesn't appear in the log when accessing DB?

For example, if you run all, the character User Load appears.User.all User Load (3.5ms) SELECT users.* FROM usersOn the other hand, when you run pluck, SQL itself seems to be the same, but User Load i...


1 answers
75 views
0
To Write Multiple Conditions LEFT JOIN in Rails

ModelA - id - c_id - d_idModelB - id - name - c_id - d_idShared columns for ModelA and ModelB are c_id and d_id.SELECT A.id, B.namefrom ModelA ASA LEFT JOIN ModelB ASB ON A.c_id = B.c_id AND A.d_id =...


2 answers
85 views
0
Please tell me how to obtain the id of the data saved in activecord.

I'd like to get the id of the data I just saved in activerecord, but I can't google it (only other information hits), so please let me know.Image data=User.create(:name=>hoge)data.id#ID of the data...

2 years ago

1 answers
92 views
0
To write this MySQL query like ActiveRecord

I'd like to count the number of blog posts daily and take a tally, but the way I write the group is redundant.Currently, the results of this query are as good as you would like, but could you write mo...

« - 2 - »

© 2024 OneMinuteCode. All rights reserved.