select DATE(created_at) as DateOnly, count(*)
where author_id = 877081418
group by DateOnly
order by DateOnly
Thursday, October 29, 2009
Thursday, October 08, 2009
Put simply, we entered
thismeant “the new object.” On the other hand, we entered
deep_thought, so while we’re executing that method,
thisis not read from the scope chain as other variables are, but instead is reset on a context by context basis.
The paragraph gave a good way to think about it: this changes based on the object that calls the method. It only gets confusing when you start passing around functions and using callbacks, which is most of the power of functional programming.
As an example, here, I was using an anonymous function as a callback in the request() method. But it doesn't work!
jQuery does not provide such a binding facility. The library’s philosophy favors closures over binding and forces users to jump through hoops (that is, manually combine lexical closures and
call, much as other libraries do internally) when they actually need to pass along a piece of code referring to “instance members.”
Wednesday, October 07, 2009
Using this validation method in conjunction with ActiveRecord::Base#save does not guarantee the absence of duplicate record insertions, because uniqueness checks on the application level are inherently prone to race conditions.
This could even happen if you use transactions with the ‘serializable’ isolation level. There are several ways to get around this problem:
By locking the database table before validating, and unlocking it after saving. However, table locking is very expensive, and thus not recommended.
By locking a lock file before validating, and unlocking it after saving. This does not work if you‘ve scaled your Rails application across multiple web servers (because they cannot share lock files, or cannot do that efficiently), and thus not recommended.
Creating a unique index on the field, by using ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the rare case that a race condition occurs, the database will guarantee the field‘s uniqueness.
Tuesday, October 06, 2009
"MethodNotAllowed: The specified method is not allowed against this resource." Error.