Positioning the column. MySQL only

zegomesjf Jun 13, 2010

Add support for MySQL column positioning via #add_column and #change_column

add_column and change_column in the MySQL adapter now accept some additional options:

:first => true # Put the column in front of all the columns

:after => column_name # Put the column after 'column_name'

clas...

No security

RurouniJones Jun 7, 2010 2 thanks

One important thing to remember is that this is NOT hidden in the source code and can be modified by an evil user so all input in a hidden field should be considered as untrustworthy and checked just like a visible field.

database exceptions will still be raised

ColinDKelley Jun 4, 2010 2 thanks

Note that save() only returns false on validation errors (when valid? returns false). If other errors occur at the database level, like a database deadlock or trying to insert null into a column that doesn't allow it, that will still raise an exception.

Naming fragment cache

hosiawak May 31, 2010 4 thanks

One of the common ways of using fragment caching is to cache content that's shared across the site (eg. left navigation, menus, widgets etc.) that looks and works the same regardless of the name of the action or controller calling it. In such cases it's very easy to just use named fragment caching e...

How using Array methods

sebthemonster May 18, 2010 2 thanks

It's not possible to use Array methods with a scope because it's not an Array but an ActiveRecord::NamedScope::Scope :

this Article.promotion.sum(&:price) doesn't run.

But you can use the to_a method to transform the ActiveRecord::NamedScope::Scope to an Array :

Article.promotion.to_a.sum...

Changes self

amasses May 3, 2010 2 thanks

This method changes the object/array the method is called on. For example:

a = ["a", "b", "c"]
b = ["x", "y", "z"]

a.concat(b)  #=> [a", "b", "c", "z", "y", "z"]
a #=> [a", "b", "c", "z", "y", "z"]

In this example the object A is modified, the method modifies the object, then re...

smtp syntax error 555 5.5.2

kares Apr 27, 2010

If You're seeing a Net::SMTPFatalError (555 5.5.2 Syntax error ...) than You should check the email's from header ! You probably have brackets while calling the from attribute setter :

=== Works in Rails < 2.3.3

def signup_notification(recipient)
  recipients      recipient.emai...

Avoid DoubleRenderError

kares Apr 25, 2010

One can not invoke render twice during an action. Thus if You have a complicated rendering logic but at the end would like to render some default content, or just would like to find out whether render has been called during the current action, use performed?. This also works with "empty" ren...