Space before the opening [

ndgiang84 Jul 1, 2015 1 thank

In this example

Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]

The array is a parameter, so a space is required before the opening [, which is equivalent to write like this

Post.find_by_sql(["SELECT title FROM posts WHERE aut...

Very bad documentation

mkopel May 1, 2015 7 thanks

This is terrible documentation. It makes it very hard to understand what the arguments mean.

The signature is

alias_method(p1, p2)

So what do p1 and p2 mean? The description doesn't refer to them at all, but to new_name and old_name. How are we supposed to know which is which?

And then it...

Prevent new line character.

joshuapinter Apr 29, 2015

To prevent the "\
" character added at the end of each file pass in the "row_sep: nil" option:

[ "some", "array" ].to_csv                 # => "some, array\

"

[ "some", "array" ].to_csv( row_sep: nil ) # => "some, array"

Link with relative url

chitra Apr 25, 2015

By default link_to opens url as absolute if path does not contain http:// or https:// For Ex.

= link_to 'View', "test123.abc.com/ag/acf", target: :_blank, title: "Click to open url in a new tab"

Then it'll open the link with absolute path not only with test123.abc.com/ag/acf.

If link_to path cont...

RSS feeds in Rails

superfeedr Apr 21, 2015

Fetching RSS feeds in the request/response cycle inside a Rails application is probably not the very best approach, as it will make your application as slow as the server serving RSS feeds. Another option is to do it asynchronously using a worker or a queue, but this can also become quite complex...

Deprecation

exadeci Apr 14, 2015

It still exists but you give it a block instead of creating a method:

==== <=2.3.8

def before_create
  self.login = self.first_name
end

==== Now

before_create :set_login

def set_login
  self.login = self.first_name
end

Typo

olitreadwell Apr 2, 2015

"Acceptable exception types maye be given as optional arguments. If the last argument is a String, it will be used as the error message."

"Acceptable exception types may be given as optional arguments. If the last argument is a String, it will be used as the error message."