execJs: ‘Could not find a JavaScript runtime’ but execjs AND therubyracer are in Gemfile

Ubuntu Users: I had the same problem and I fixed it by installing nodejson my system independent of the gem. on ubuntu its: sudo apt-get install nodejs I’m using 64bit ubuntu 11.10 update: From @Galina ‘s answer below I’m guessing that the latest version of nodejs is required, so @steve98177 your best option on a … Read more

Ruby on Rails Callback, what is difference between :before_save and :before_create?

In a create operation under Rails, there are six callbacks before the database operation, and two after. In order, these are: before_validation before_validation_on_create after_validation after_validation_on_create before_save before_create DATABASE INSERT after_create after_save Update operations have exactly the same set, except read update instead of create everywhere (and UPDATE instead of INSERT). From this, you can see … Read more

What is the right way to override a setter method in Ruby on Rails?

=========================================================================== Update: July 19, 2017 Now the Rails documentation is also suggesting to use super like this: class Model < ActiveRecord::Base def attribute_name=(value) # custom actions ### super(value) end end =========================================================================== Original Answer If you want to override the setter methods for columns of a table while accessing through models, this is the way to … Read more

Rails: Installing PG gem on OS X – failure to build native extension

Same error for me and I didn’t experience it until I downloaded OS X 10.9 (Mavericks). Sigh, another OS upgrade headache. Here’s how I fixed it (with homebrew): Install another build of Xcode Tools (typing brew update in the terminal will prompt you to update the Xcode build tools) brew update brew install postgresql After … Read more