小ネタ。 Rails 5から、production environmentでのDB破壊系のtaskの実行を防止する仕組みが入りました。 例えば、production environmentでdb:dropを実行しようとすると、下記のようなエラー(ActiveRecord::ProtectedEnvironmentError)が発生します。 $ RAILS_ENV=production ./bin/rails db:drop rails aborted! ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database If you are sure you want to continue, run the sa
Today we are open-sourcing our ODBC adapter for ActiveRecord, which allows Ruby on Rails applications to communicate with ODBC-compliant databases. The impetus for this work was an effort to update one of our APIs to run with the latest Rails and ruby. Along the way we released Rails 3.2.x, 4.2.x, and 5.0.x versions of the adapter, along with deploying incremental upgrades to our API as we went. B
I'm on Ruby 1.9.2, Rails 3.0.x and I use MySQL DB. I have a Messages Model, where one can post new messages every day. I have an index action where I want to display these messages grouped by both month and year. This basically is used to filter messages. My query looks like this:- @active_msgs = Messages.where('expiry > ?', Time.now).order('created_at DESC') I used the group_by function in Rails,
So I have a model that I want to retrieve records and group them by dates of the created_at field. But created_at is a datetime field, and I am only interested in the date part. So I am looking for something like a 2D array, first layer would a hash with date string as the key, second layer would be arrays with records. How should I do it? { "9/28/2012" => [record, record, record], "9/29/2012" =>
以前に書いたコードを読んでいると、1カラムの値だけを変えるからといって、update_attribute メソッドを使っている部分があった。これはあまりよくない update_attribute とupdate_attribtues の違い 前者は1つのカラムの値を、後者は複数のカラムの値を更新できる。という違い以上に、「update_attribute メソッドはvalidation なしに更新、update_attributes メソッドはvalidation ありで更新」という違いがあります。 つまり、update_attribute 使うと、検証処理なしに、値が更新されてしまう。ソースを見ると、update_attribute の方は、save(false) を使って更新しているのが分かる。 activerecord/lib/active_record/base.rb at mas
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
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く