RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Submit a post

You can use basic HTML markup (e.g. <a>) or Markdown.
Note that your post may be edited to suit the format of the site.

As you are not logged in, you will be
directed via GitHub to signup or sign in

Post Preview

Note: Only the first pargraph is shown on the front page and overly long paragraphs may be broken up.

Mongoid (MongoDB) has_many/belongs_to relation and wrong index being picked

If you have issues with your Mongoid relations and wrong indexes being picked, you may want to look here: Mongoid (MongoDB) has_many/belongs_to relation and wrong index being picked.

Link broken since it thinks your href is a relative one
@PIKACHUEXE: Already fixed :)

When edge cases poke holes in your perfect solution

You found the perfect solution to your crazy testing problem. All you have to do is override DEFAULT_HOST, and you’ll be in business. Except that you have to turn off warnings. And you have to figure out that one test where you don’t want to override the host. And then… Except… [more inside]

Recalculate counter cache columns in Rails

Rails has this great feature called counter_cache. When you have a has_many/belongs_to relationship between two models, it basically lets you say that you want to save the number of associated objects on the has_many side. So if you have Post has many Comments, you can do post#size and no SQL query is executed, Rails simply just looks at the comments_count field of the post. [more inside]

Loading older posts