When should I not kill -9 a process? - And what to do instead.
CoffeeScript 1.7.0 - A new release with some breaking changes is out.
The two biggest bugs fixed in - Well, debatable, but some important ActiveRecord fixes are coming. 4.1
The code above makes sure that we scope ActiveRecord methods to a merchant, but it doesn't cover all cases. For example, it doesn't stop code like this:
Customer. find_by_sql ( [ "SELECT * FROM customers WHERE token = ?" , "Paul" ] )
We write a decent amount of custom SQL in our application for performance, and we wanted to make sure these cases were safe as well. Therefore, we have a similar hack called the scoped find hook that checks ActiveRecord objects …
This advice is going on a year old, but it's still some of the best around. If you've got ungainly ActiveRecord objects that are doing way more than abstracting your data model, you are missing classes in the design of your application. Chances are, one of the objects describes here is what you might want to extract.
Unnecessary round-tripping to the database server and models with lots of callbacks, uniqueness checks, and other slow code can still slow down your test suite. A lot of methods and validations on a model can be tested without saving it.
Avoid connecting to remote services
You don't …
We can understand why factories are slow by looking at why ActiveRecord fixtures are fast.
Fixtures are bulk loaded once. A transaction is created in the database when a test starts. After the test the database is rolled back to its initial state. This means the fixtures don't have to be reloaded for each test.
Most factory implementations start a test with an empty database and run through all the factories needed for a test each time it's run. After the test the database is reset …
…definitely feature if I ever do get that opportunity: more and more, I like to avoid including modules into ActiveRecord and other parts of the absolute minimum to ActiveRecord::Base, plus I've pulled out the logic around the tag names collection and resulting persistence into a separate, simple class .- and if you peruse the source you'll see I'm only adding
I got a nice little buzz when I had Code Climate scan the source and give it …
This means that your ActiveRecord instances take priority - so pane methods don't overwrite your own code. It also allows for method_missing metaprogramming in your models (and ActiveRecord itself) - but otherwise, you can get access to the useful metadata Sphinx can provide, without monkeypatching objects on the fly.
If you're writing your own panes, the only requirement is that the initializer must accept three arguments: the search context, the underlying search result object, …
It sounds great in theory, but it's harder in practice.
It's good to be aware of such hidden functionalities. At some point, they can become explicit features, with their own tests, so that it's never broken.
If you know more such features, share them in the comments.
In the previous post, I highlighted the typical , that I encountered during my research on better ways of working on Rails apps. The bugs were often security-related: bugs
The main common point of the bugs is the ActiveRecord overdose.
ActiveRecord overdose is a surprisingly popular pattern that includes:
putting everything into the model class
fear of adding new non-AR classes
over-relying on convention over configuration When you look at a typical Rails model, …
…of heart . Some parts of the Rails framework are very ambitious engineering — take ActiveRecord, for example. As is true with most software projects, even the people who wrote it the first time don't fully understand what it is doing. You get to start working on rebuilding their undocumented organic knowledge now, and doing security patches later. You might think that you have a helpful ally in the test suite but it is not actually deterministic, because many of the tests rely on …