Recently upgraded to Rails 5. There seems to be some compatibility issue, in particular when I run “rails c” or “rails s”.

The warning message is

Array values in the parameter are deprecated. Please use a String or nil. Fixed by applying the same join you see here to the line 11 of bin/spring:
Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(File::PATH_SEPARATOR) }

How to push the code to the remote repository and deploy to Heroku

$git add -A

$git commit -m "made some improvements"

$git checkout master

$git merge test_branch_name

$git push

$git push heroku

$heroku pg:reset DATABASE

$heroku run rake db:migrate

$heroku run rake db:seed

There you go…


I would like to take information from another website. Therefore (maybe) I should make a request to that website (in my case a HTTP GET request) and receive the response.

How can I do this in Ruby on Rails?

If it is possible, is it a correct approach to use in my controllers?

Answer #1:

You can use Ruby’s Net::HTTP class:

require 'net/http'

url = URI.parse('')
req =
res = Net::HTTP.start(, url.port) {|http|
puts res.body

Answer #2:
You could write a method to do this in the controller

  def api_request(type , url, body=nil, header =nil )
    require "net/http"
    uri = URI.parse(url)
    case type
    when :post
      request =
      request.body = body
    when :get
      request =
    when :put
      request =
      request.body = body
    when :delete
      request =
    #request.content_type = 'application/json'
    response = Net::HTTP.start(, uri.port, :use_ssl => uri.scheme == 'https') {|http| http.request request}

Answer #3:
A general example of using Ruby Net::http
 url = URI.parse('')
 req =
 http =, url.port)
 http.use_ssl = (url.scheme == "https")
 response = http.request(req)
 puts response.body


Question: Should people store JSON object in the database file as a string?

Size is not so much of an issue, the ability to query and maintain the data however is.

If, for example, Greenhaven Press decides they want to change their name to Greenhaven Press International, you’ll have to find the record, deserialize it, change it, serialize it, pump it back into the database.

Consider this: does storing these objects as serialized data offer you a clear added value over storing it in a relational form? If the answer is no, then it might not be worth the hassle.


As far as your update of your question goes: I’m inclined to say no, it makes little or no difference. Whether you update one field or all of them in this json string is irrelevant because the whole process is identical.

Don’t forget that your requirements might change; even though you’re using json on the client side now doesn’t mean you’ll need json in the future. Storing your data in a relational form guarantees technology-independence while preserving relationships, data constraints and queryable metadata: this is where the true value of a relational db lies. Discarding those advantages will neither give you a performance gain nor make your application more scalable or flexible.

Question: how to access a Rails app from another computer on the same LAN?
rails server -b myipaddress -p 3000
Your firewall may block 80; so try another port instead.
Question: issue with loading a gem?

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require’: cannot load such file — cassandra (LoadError)

Answer:Rubygems are separated by ruby version, so you need to reinstall the Cassandra gem:

gem install cassandra

Make sure that gem is pointed to the 1.9 gem.

The main reason you need to do this is to rebuild the C extensions against the 1.9 libraries.

When using Sublime Text for any scripting language such as Ruby, sometimes you will need to be flexible and change the build system (e.g., path to the interpreter).
Rails authentication gems: Devise and devise_token_auth.
Question: Where is Rails Helper available?



The bottom line answer is the application_helper is available in all your views.

Rails actually uses helpers all over the place – in everything from the likes of form_for to other built-in Rails methods.

As Rails is basically just a series of classes & modules, the helpers are loaded when your views are rendered, allowing you to call them whenever you need. Controllers are processed much earlier in the stack, and thus you have to explicitly include the helpers you need in them

Important – you don’t need to include the ApplicationHelper in your ApplicationController. It should just work

Rails 5. 2 has capability to include node.js package (via Yarn and Webpacker).
Question: How to update rbenv (rbenv is out of date) to include all ruby build versions
cd ~/.rbenv
git pull

cd ~/.rbenv/plugins/ruby-build/
git pull