RailsCasts Pro episodes are now free!

Learn more or hide this

Alexander Zaytsev's Profile

GitHub User: AlexanderZaytsev

Site: https://twitter.com/AlexandrZaytsev

Comments by Alexander Zaytsev

Avatar

Tip: to check if a value is set on a field, Rails provides you with methods that end with a question mark. So your price_in_dollars method will look like this:

ruby
  def price_in_dollars
    price_in_cents.to_d/100 if price_in_cents?
  end

It's a small but neat change.

Also, speaking of prices, there is an excellent gem called money-rails for handling that: https://github.com/RubyMoney/money-rails

Avatar

Thank you very much, Scott!

I had to add "libmagickwand-dev" as well to make it work.

Rubber seems to be a really great tool :)

Avatar

Do you have experience with installing RMagick with Rubber on an instance? What is the best way to do it? I can simply ssh to the instance and install it manually, but it doesn't feel right.

Avatar

You can use it this way:

ruby
%div{:data => {"pjax-container" => true}}

It is especially handy when you have several "data-" attributes, this way you don't have to repeat the "data-" part.