Missing host to link to!

So I was outputting URL from a rails model with


but my specs were complaining with

Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

after some googling and trial and errors I found that this line would did the trick. Put it in your test_helper or spec_helper

Rails.application.routes.default_url_options[:host] = 'localhost:3000'

cheers :D