Why “bundle install” a gem instead of “gem install” for a rails 3 app?

Using bundler instead of gem command to directly install your gems gives you a whole lot of benefits. In this specific case where you suggest using the gem command to install and adding it later to the Gemfile, bundler will resolve all the dependencies for you when you install a gem, which you might have … Read more

How to solve the update bundler warning in rails when deploying to heroku?

So it’s complaining that the version of bundler installed on heroku is older than the version you used to create your Gemfile.lock on your dev machine. You can probably just ignore the warning — in most cases installing with a slightly older version of bundler than you used to create the Gemfile.lock is just fine. … Read more

cannot load railtie after upgrade to rails 4 per ruby.railstutorial.org

ActiveResource was an API added in Rails 2.x to support an XML (and later JSON) API so that Rails sites could “talk” to one another. It was a very hot topic when the idea of RESTful APIs made its way into the framework. Over time it became more of a novelty and infrequently maintained so … Read more

Why use ‘reload’ method after saving object? (Hartl Rails Tut 6.30)

Yes in this case @user.reload.email and @user.email is the same thing. But it’s good practice to use @user.reload.email instead of @user.email to check what is exactly saved in the database i mean you don’t know if you or someone add some code in after_save which changes it’s value then it will not have effect on … Read more

Bundle Install could not fetch specs from https://rubygems.org/

Just in case none of the above satisfies the next intrepid explorer, I thought I’d drop here that after I spent 4 hours on this doing variants of the search that landed me here, I finally discovering that IPV6 was the culprit, after finding this specific thread on help.rubygems.org. Solution? this (Fedora, Linux): sudo sysctl … Read more

Confused about ‘respond_to’ vs ‘respond_to?’

Ruby treats ? and ! as actual characters in a method name. respond_to and respond_to? are different. ? indicates that this should respond with a true or false (by convention; this is not a requirement). Specifically: respond_to? is a Ruby method for detecting whether the class has a particular method on it. For example, @user.respond_to?(‘eat_food’) … Read more

tech