1.0.0 1.1.0 1.1.1 1.1.6 1.2.0 1.2.6 2.0.0 2.0.1 2.0.3 2.1.0 2.2.1 2.3.2 2.3.8 3.0.0 3.0.5 3.0.7 3.0.9 3.1.0 3.2.3 3.2.8 3.2.13 4.0.0 4.1.0 4.2.1
1.0.0 1.1.0 1.1.1 1.1.6 1.2.0 1.2.6 2.0.0 2.0.1 2.0.3 2.1.0 2.2.1 2.3.2 2.3.8 3.0.0 3.0.5 3.0.7 3.0.9 3.1.0 3.2.3 3.2.8 3.2.13 4.0.0 4.1.0 4.2.1
A better way to import all your records using ActiveRecord Import! Hi there! I’m here to tell you about a Rails gem that has saved me some time and that could save you some time too. The gem’s name is ActiveRecord Import, but before I get into what it does let me first describe the problem I was facing. The Problem Imagine a big system with two databases and with lots of users, in the tens of thou
Wenn die Beziehung mit dem Tierarzt bei der Katze nicht sofort funktioniert für die benachbarten Katzen, wurde sie während des Umzugs fast ihre. Ein gewisser Teil der Vorsicht in der Kommunikation mit ihr blieb bei den benachbarten Katzen nur aus dem Grund, dass niemand im Auto wusste, warum sie mit ihnen fahren. Die Annahmen waren unterschiedlich, aber keine davon hat sich als allgemein anerkannt
If you've used Rails, you've likely used Active Record as a way to access and record database transactions in a more Ruby-like manner. Active Record goes a long way in simplifying the use of a database. But more then that, it's designed in such a way that we don't have to worry about the particulars for working with specific databases. The mapping for each database is stored and handled within Act
Enable the query cache within the block if Active Record is configured. If it’s not, it will execute the given block. # File activerecord/lib/active_record/query_cache.rb, line 9 def cache(&block) if connected? || !configurations.empty? pool = connection_pool was_enabled = pool.query_cache_enabled begin pool.enable_query_cache(&block) ensure pool.clear_query_cache unless was_enabled end else yield
Photo by Kayla KandzorraActiveRecord does not touch updated_at by default when calling: ActiveRecord::Base#update_columnActiveRecord::Base#update_columnsActiveRecord::Relation#update_allThis was causing some unexpected issues with caching and incremental ETL to external systems since our usage of updated_at to signify data modifications was inconsistent. We realized that we rarely ever have a reas
Set.new([:where, :select, :group, :order, :lock, :limit, :offset, :joins, :left_outer_joins, :annotate, :includes, :eager_load, :preload, :from, :readonly, :having, :optimizer_hints, :with]) Returns a new relation, which is the logical intersection of this relation and the one passed as an argument. The two relations must be structurally compatible: they must be scoping the same model, and they mu
Is there a way that you can get a collection of all of the Models in your Rails app? Basically, can I do the likes of: - Models.each do |model| puts model.class.name end
# File activerecord/lib/active_record/secure_token.rb, line 61 def generate_unique_secure_token(length: MINIMUM_TOKEN_LENGTH) SecureRandom.base58(length) end Example using has_secure_token # Schema: User(token:string, auth_token:string) class User < ActiveRecord::Base has_secure_token has_secure_token :auth_token, length: 36 end user = User.new user.save user.token # => "pX27zsMN2ViQKta1bGfLmVJE"
In programming language terms, “laziness” refers to code whose evaluation is delayed until the last possible moment. This strategy can have several benefits. For example: nums = (1..1_000_000).lazy squares = nums.map { |x| x * x } squares.take_while { |x| x < 100 }.to_a #=> [1, 4, 9, 16, 25, 36, 49, 64, 81]In this (contrived) example, since we're using a lazy enumerator, we never actually calculat
Active Record Validations Active Record includes the majority of its validations from ActiveModel::Validations. In Active Record, all validations are performed on save by default. Validations accept the :on argument to define the context where the validations are active. Active Record will pass either the context of :create or :update depending on whether the model is a new_record?.
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く