rails-activerecord tag

33 questions


1 answers
67 views
0
warning —already initialized constant APP_PATH

The rails suddenly stopped working...This is the log displayed.>bin/rails:6:warning:already initialized constant APP_PATH>/Users/Sean/Desktop/Renascence/bin/rails:6:warning:previous>definitio...


1 answers
81 views
0
Understanding Rails Model Relationships

Let's talk about the following models.idtitleidnameI would like to add created_user_id and updated_user_id to Post. What should I do?If you want to add user_id, raid migration AddUserIdToPost user_id:...


1 answers
64 views
0
To select controls the columns of the models associated with rails

when you want to limit which columns are retrieved using selectHow do I control the columns of the relevant model as well?Post>--CategoryI only want to get title for Post and name for Category.Imag...


1 answers
77 views
0
ActiveRecord::InvalidForeignKey does not raise

studentssubjectsstudents_subjects (intermediate table)student_idsubject_idstudent_idsubject_idThe students_subjects have foreign key constraints in the migration file.I wanted to check if foreign key ...


1 answers
65 views
0
ActiveRecord validations, uniquness conditioning

in ActiveRecord::Base validationsSelect multiple columns in uniquness and Also, is it possible to add the value of the column to the conditions?What do you want to be uniquness?- user_id- mst_category...


2 answers
72 views
0
Learn how to use build (ActiveRecord) to set two foreign keys associated with the parent during new registration.

| id | name | | id | area_id | name | | id | perfect_id | name | | id | perfect_id | perfect_area_id | name | I would like to store the data using build as follows. | id | name | | -- | ---- || 1 | Ki...


2 answers
76 views
0
How do I check ActiveRecord memory usage?

As for ActiveRecord for rails, I think it caches SQL query results.In the log, click Model name Load (0.8ms) SELECT and belowSave the and Load to cache and display the query execution time.CACHE (0.1m...


1 answers
70 views
0
Understanding Extracting After Combining Rails 3 Tables

I'm a beginner at Rails and SQL, so I'm sorry if there are any expressions that are difficult to understand.First, we have the following models: class City<ActiveRecord::Base has_many —favorites ha...


1 answers
62 views
0
How do I quickly switch between multiple DBs in rails?

Environment: ruby 2.1.3, rails 4.2, activaterecord-sqlserver-adapter 4.1If you have to switch from place to place to place to process 20 databases.First, prepare an array (specs) containing connection...


3 answers
78 views
0
Implementation of making models have uuid in rails

Currently, uuid is achieved by adding the following actions to the User model:def before_save_action_name uuid=SecureRandom.uuid uuid=SecureRandom.uuid while User.exists?(:uuid=>uuuid) self.uuid=uu...

« - 3 - »

© 2024 OneMinuteCode. All rights reserved.