Heroku throws OpenURI::HTTPError (403 Forbidden): - ruby-on-rails

I have a Rails 4 Application serving up JSON data to a BackboneJS frontend client. The backend scrapes some content from Craigslist and serves it to the frontend as JSON. Locally, in development, it works just as expected.
On Heroku, the application layout does get served correctly and assets seem to load just fine. It isn't until backboneJS queries for data to fill the appropriate view, and there the app fails due to the OpenURI error.
More specifically, OpenURI keeps returning the
OpenURI::HTTPError (403 Forbidden)
when executing the following line in the Rails controller:
open( "#{clist.url}" )
I have spent several hours trying various 'solved' solutions I have found on Stack Overflow and Github and just trying to look through the Heroku logs for other errors, but the error remains no matter which suggested 'solutions' I try out.
As of now, I have tried the following suggested solutions, along with several other silly ones:
Required open-uri in my application controller
Added the 'User-Agent' key to my open method call
Changed the clist.url from "https" to "http" to avoid redirects
Also, the app is straight forward and doesn't require authentication at the moment either.
Apart from Stack Overflow and github, I couldn't find any suggested solutions elsewhere. Any help with any suggestions on other debugging tips to try or suggested solutions would be extremely appreciated. I am fairly new to Heroku, so still getting acquainted with debugging issues like this on a remote production engine.
Here is the relevant code that fetches from Craigslist (don't judge me too harshly. All/Most of this method is set to be refactored and put into it's own Class/Model, which is where it belongs ):
def index
#listings = []
#Retrieve job listings from Craigslist (see method sync_list below ... )
#raw_listings = sync_clist
# filters applied at this point ...
# and they transform #raw_listings to ...
# the array #listings
render json: #listings
end
def sync_clist
##search_items = SearchItem.all
#search_items = SearchItem.all[0..1]
site = #sites[0]
# in the Craigslist HTML, the second element in the returned job listing # is the better one to use
href_idx = 1
##### LINE 123 is the next one:
#search_items.each_with_index do |search_item, idx|
puts "#{search_item.url.upcase}"
##### LINE 125 ... FAILURE_HERE? *****************
html = open( "#{search_item.url}", 'User-Agent' => "Ruby/#{RUBY_VERSION}")
page = Nokogiri::HTML( html.read, nil, 'utf-8' )
category_idx = idx % 4
isNearby_listing = false #also capture 'nearby' jobs on Craigslist
page.css( site[:joblist_css] )[0..-2].each_with_index do |listing, i|
# convert the relative url in the list to a full-url
locale_idx = idx/#clist_locales.length
listing_url = listing.css('a')[href_idx]['href']
# Craigslist only lists the relative path of job urls - relative to the
# current search location. The 'More Local' items, however, return the
# full url.
if !isNearby_listing
posting_url = site[:protocol] + site[:locales][locale_idx] + "." + site[:host] + listing_url
else
posting_url = listing_url
end
# Once the appropriate heading is reached, the 'More Local' listings
# items begin appearing
if listing.next_sibling.node_name == 'h4'
isNearby_listing = true
end
posting_date = listing.css('time')[0]['datetime']
job_listing = { :source => site[:sitename].upcase,
:title => listing.css('a')[href_idx].text,
:url => posting_url,
:listing_id => listing["data-pid"],
:location => #clist_locales[locale_idx],
:content => "",
:telecommute => "",
:contract => "",
:pt_ft => "",
:favorite => false,
:posted_date => posting_date,
:category => #clist_categories[category_idx],
:apply_state => "new"
}
#new_listings << job_listing
end
end
#new_listings
end
Here is the output of my Heroku logs in case it helps:
```
2015-04-27T03:47:14.611278+00:00 app[web.1]: => Rails 4.0.8 application starting in production on http://0.0.0.0:43688
2015-04-27T03:47:14.611280+00:00 app[web.1]: => Run `rails server -h` for more startup options
2015-04-27T03:47:14.611310+00:00 app[web.1]: Started GET "/" for 24.5.106.52 at 2015-04-27 03:47:14 +0000
2015-04-27T03:47:14.611272+00:00 app[web.1]: => Booting WEBrick
2015-04-27T03:47:14.611281+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-04-27T03:47:14.664777+00:00 app[web.1]: Rendered app/root.html.erb within layouts/application (0.5ms)
2015-04-27T03:47:14.661735+00:00 app[web.1]: Processing by AppController#root as HTML
2015-04-27T03:47:14.664783+00:00 app[web.1]: Rendered app/root.html.erb within layouts/application (0.5ms)
2015-04-27T03:47:14.674604+00:00 app[web.1]: Completed 200 OK in 13ms (Views: 12.3ms | ActiveRecord: 0.0ms)
2015-04-27T03:47:14.674612+00:00 app[web.1]: Completed 200 OK in 13ms (Views: 12.3ms | ActiveRecord: 0.0ms)
2015-04-27T03:47:14.611302+00:00 app[web.1]: Started GET "/" for 24.5.106.52 at 2015-04-27 03:47:14 +0000
2015-04-27T03:47:14.661749+00:00 app[web.1]: Processing by AppController#root as HTML
2015-04-27T03:47:15.943141+00:00 heroku[router]: at=info method=GET path="/assets/application-45c34fbd86efe641e061caa3b34737d7.css" host=APPNAME.herokuapp.com request_id=dbf8473e-2880-42f6-8ef4-11e0da7141b4 fwd="24.5.106.52" dyno=web.1 connect=2ms service=73ms status=200 bytes=569692
2015-04-27T03:47:15.944069+00:00 heroku[router]: at=info method=GET path="/assets/application-537f60efd0378faaddaea08875f25055.js" host=APPNAME.herokuapp.com request_id=5c7cf6db-393f-434e-a494-d3664d31a20f fwd="24.5.106.52" dyno=web.1 connect=2ms service=70ms status=200 bytes=965489
2015-04-27T03:47:17.631614+00:00 app[web.1]: Started GET "/posts" for 24.5.106.52 at 2015-04-27 03:47:17 +0000
2015-04-27T03:47:17.631624+00:00 app[web.1]: Started GET "/posts" for 24.5.106.52 at 2015-04-27 03:47:17 +0000
2015-04-27T03:47:17.636842+00:00 app[web.1]: Processing by PostsController#index as JSON
2015-04-27T03:47:17.636831+00:00 app[web.1]: Processing by PostsController#index as JSON
2015-04-27T03:47:17.665568+00:00 app[web.1]: HTTP://SFBAY.CRAIGSLIST.ORG/SEARCH/SOF?QUERY=RAILS
2015-04-27T03:47:18.048174+00:00 heroku[router]: at=info method=GET path="/posts" host=APPNAME.herokuapp.com request_id=a2724fb9-6872-4435-8dfc-0df1b73fb761 fwd="24.5.106.52" dyno=web.1 connect=2ms service=417ms status=500 bytes=330
2015-04-27T03:47:18.042116+00:00 app[web.1]: Completed 500 Internal Server Error in 405ms
2015-04-27T03:47:18.043586+00:00 app[web.1]: OpenURI::HTTPError (403 Forbidden):
2015-04-27T03:47:18.042129+00:00 app[web.1]: Completed 500 Internal Server Error in 405ms
2015-04-27T03:47:18.043590+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `each'
2015-04-27T03:47:18.043588+00:00 app[web.1]: app/controllers/posts_controller.rb:125:in `block in sync_clist'
2015-04-27T03:47:18.043593+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `sync_clist'
2015-04-27T03:47:18.043584+00:00 app[web.1]:
2015-04-27T03:47:18.043591+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `each_with_index'
2015-04-27T03:47:18.043596+00:00 app[web.1]:
2015-04-27T03:47:18.043594+00:00 app[web.1]: app/controllers/posts_controller.rb:53:in `index'
2015-04-27T03:47:18.043597+00:00 app[web.1]:
2015-04-27T03:47:18.043602+00:00 app[web.1]:
2015-04-27T03:47:18.043604+00:00 app[web.1]: app/controllers/posts_controller.rb:125:in `block in sync_clist'
2015-04-27T03:47:18.043603+00:00 app[web.1]: OpenURI::HTTPError (403 Forbidden):
2015-04-27T03:47:18.043606+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `each'
2015-04-27T03:47:18.043607+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `each_with_index'
2015-04-27T03:47:18.043610+00:00 app[web.1]: app/controllers/posts_controller.rb:53:in `index'
2015-04-27T03:47:18.043609+00:00 app[web.1]: app/controllers/posts_controller.rb:123:in `sync_clist'
2015-04-27T03:47:18.043613+00:00 app[web.1]:
2015-04-27T03:47:18.043611+00:00 app[web.1]:
```

Taking #TarynEast's suggestion and running app code in the Heroku console, I switched to using the 'net/http' library instead of 'open-uri' to retrieve the Craigslist webpage. The following message was returned by Craigslist when using 'net/http':
"This IP has been automatically blocked.\nIf you have questions, please email: blocks-b1402369961264436#craigslist.org\n"
So, apparently, either all of Heroku IPs have been blocked, or, more likely, it's just my app specifically that has been blocked even though my app only pings craigslist at most 8 times per site load. Maybe that was enough to block it since Craigslist is a very popular target of scraping apps. Anyways, mystery solved as to why the 403 Error. At least app still works locally.
[Update:] According to a quick Google search, Craigslist blocks the entirety of AWS and Heroku IPs, amongst others. See SO question here: Craigslist blocking Heroku/AWS

I had a similar issue when I had a Rails app hosted on Heroku opening a file held on S3. I got the same error because the URL was wrong.

Related

Ruby on rails app works on local host but, not on heroku

I just learn ruby on rails. I created two database table: trainers and tokimons. Everything works fine on local host(including database), but something went wrong on heroku.
Here is the log:
2016-10-13T21:51:16.840425+00:00 heroku[router]: at=info method=GET path="/" host=a2-tokimon.herokuapp.com request_id=2f86b075-8d64-4616-984a-304df86d9768 fwd="142.58.35.51" dyno=web.1 connect=2ms service=11ms status=500 bytes=1669
2016-10-13T21:51:16.851541+00:00 app[web.1]: Started GET "/" for 142.58.35.51 at 2016-10-13 21:51:16 +0000
2016-10-13T21:51:16.854395+00:00 app[web.1]: Processing by WelcomeController#index as HTML
2016-10-13T21:51:16.858208+00:00 app[web.1]: Rendered welcome/index.erb within layouts/application (3.1ms)
2016-10-13T21:51:16.858340+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms (ActiveRecord: 2.3ms)
2016-10-13T21:51:16.859867+00:00 app[web.1]:
2016-10-13T21:51:16.859872+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "trainers" does not exist
2016-10-13T21:51:16.859873+00:00 app[web.1]: LINE 1: SELECT "trainers".* FROM "trainers"
2016-10-13T21:51:16.859874+00:00 app[web.1]: ^
2016-10-13T21:51:16.859874+00:00 app[web.1]: : SELECT "trainers".* FROM "trainers"):
2016-10-13T21:51:16.859875+00:00 app[web.1]: 51:
2016-10-13T21:51:16.859876+00:00 app[web.1]: 52:
2016-10-13T21:51:16.859877+00:00 app[web.1]: 53: <tbody>
2016-10-13T21:51:16.859877+00:00 app[web.1]: 54: <% #trainer.each do |trainer| %>
2016-10-13T21:51:16.859878+00:00 app[web.1]: 55: <tr class="<%= cycle('oddline', 'evenline') %>">
2016-10-13T21:51:16.859879+00:00 app[web.1]: 56: <td><%= trainer.pname %></td>
2016-10-13T21:51:16.859880+00:00 app[web.1]: 57: <td><%= trainer.level %></td>
2016-10-13T21:51:16.859881+00:00 app[web.1]: app/views/welcome/index.erb:54:in `_app_views_welcome_index_erb__3990380873615253162_69847032979680'
2016-10-13T21:51:16.859882+00:00 app[web.1]:
2016-10-13T21:51:16.859882+00:00 app[web.1]:
Here is a portion of trainers_controller.rb
class TrainersController < ApplicationController
before_action :set_trainer, only: [:show, :edit, :update, :destroy]
# GET /trainers
# GET /trainers.json
def index
#trainer = Trainer.all
end
Here is a portion of welcome_controller.rb
class WelcomeController < ApplicationController
# GET /welcome
def index
#trainer = Trainer.all
end
end
the line:
2016-10-13T21:51:16.859872+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "trainers" does not exist should be a hint that you have a postgres issue. Specifically that the tables are undefined.
Assuming you have heroku-cli installed, you'll need to run heroku run rake db:migrate in the console this will perform the migrations needed for Heroku.
Here is the documentation on how to get a Rails (4) app running on Heroku:
https://devcenter.heroku.com/articles/getting-started-with-rails4
And specifically here is the part about migrations:
https://devcenter.heroku.com/articles/getting-started-with-rails4#migrate-your-database
Heroku CLI documentation and installation instructions:
https://devcenter.heroku.com/articles/heroku-command-line
PG::UndefinedTable and PG::UndefinedColumn errors occur because you have not run the migrations against the production database.
You should make a habit of running heroku run rake:db:migrate after each deployment.

Why would I get 2 different API responses from a staging and production environment in Rails 4.2?

So I'm querying an api in rails 4.2 with limit and offset parameters, and I get 2 different responses in staging and production environments - production errors out. Do you have any idea why it would work in one environment but not the other? Below are the logs. I'm using the rocket_pants gem for the api. How would I approach debugging something like this?
Staging response:
2015-01-31T01:42:41.650830+00:00 app[web.2]: Processing by Api::V1::KitesController#index as
2015-01-31T01:42:41.650902+00:00 app[web.2]: Parameters: {"limit"=>"10", "offset"=>"0", "version"=>"1"}
2015-01-31T01:42:42.970394+00:00 app[web.2]: Completed 200 OK in 1319ms
Production response:
015-01-31T01:45:30.290621+00:00 app[web.2]: Started GET "/1/kites?limit=10&offset=0" for 120.131.46.189 at 2015-01-31 01:45:30 +0000
2015-01-31T01:45:30.293135+00:00 app[web.2]: Parameters: {"limit"=>"10", "offset"=>"0", "version"=>"1"}
2015-01-31T01:45:30.292819+00:00 app[web.2]: Processing by Api::V1::KitesController#index as
2015-01-31T01:45:31.219974+00:00 heroku[router]: at=info method=GET path="/1/kites?limit=10&offset=0" host=kites.herokuapp.com request_id=3ca59d79-bf90-41e9-a828-ba8bd5d5b0c6 fwd="120.131.46.189" dyno=web.2 connect=1ms service=922ms status=500 bytes=581
2015-01-31T01:45:31.196390+00:00 app[web.2]: Exception occured: NoMethodError - undefined method `id' for #<Hash:0x007f03d6ec5320>
2015-01-31T01:45:31.196402+00:00 app[web.2]: Exception backtrace:
2015-01-31T01:45:31.196659+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/respondable.rb:129:in `respond_with_object_and_type'
2015-01-31T01:45:31.196699+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/respondable.rb:134:in `resource'
2015-01-31T01:45:31.196454+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/caching.rb:69:in `cache_key_for'
2015-01-31T01:45:31.196494+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/caching.rb:55:in `etag_for'
2015-01-31T01:45:31.196534+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/caching.rb:117:in `cache_response'
2015-01-31T01:45:31.196570+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/caching.rb:130:in `post_process_exposed_object'
2015-01-31T01:45:31.196773+00:00 app[web.2]: => /app/app/controllers/api/v1/clinical_trials_controller.rb:22:in `index'
2015-01-31T01:45:31.196737+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/rocket_pants-1.9.2/lib/rocket_pants/controller/respondable.rb:155:in `exposes'
2015-01-31T01:45:31.196808+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/base.rb:198:in `process_action'
2015-01-31T01:45:31.196842+00:00 app[web.2]: => /app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.0/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
If by responses you mean what you see showing up in the log files, different environments have different default logging levels.
Here are two links that may be helpful:
http://uplifted.net/programming/debugging-rails-errors-on-heroku/
https://devcenter.heroku.com/articles/multiple-environments

Rails routes in production are looking for param: id. How do I tell it to use :order_id?

I recently connected a remote DB to the production version of my site. However, now my routes do not work.
In my Heroku logs, my app is looking for Parameters: {"id"=>"edit"}.
But there is not an :id parameter in my database. The only index specified is order_id.
How can I edit routes.db so that the order_id is used in my paths? And is this even necessary or is there something else I should look at?
List of columns in local db:
1.9.3-p392 :001 > Order.column_names
=> ["order_id", "product_status", "img_reference", "img_source", "user_email", "user_name", "user_address", "user_city", "user_zipcode", "user_state", "product_size", "product_type", "payment_id", "image_file_name", "image_content_type", "image_file_size", "image_updated_at"]
List of columns in remote db:
irb(main):001:0> Order.column_names
=> ["order_id", "order_date", "product_status", "img_reference", "img_source", "user_email", "user_name", "user_address", "user_city", "user_zipcode", "user_state", "product_size", "product_type", "uservendor_id", "paypal_confirmation"]
Again, my routes seem to work just fine in my development version.
The only difference I can think of is there's a few extra columns in my remote db which I don't think should effect the routes.
This is the error I get in my Heroku logs:
2014-05-08T15:28:55.461192+00:00 app[web.1]: Started GET "/orders//edit" for 76.102.227.168 at 2014-05-08 15:28:55 +0000
2014-05-08T15:28:55.465958+00:00 app[web.1]: Processing by OrdersController#show as HTML
2014-05-08T15:28:55.461180+00:00 app[web.1]: Started GET "/orders//edit" for 76.102.227.168 at 2014-05-08 15:28:55 +0000
2014-05-08T15:28:55.465965+00:00 app[web.1]: Processing by OrdersController#show as HTML
2014-05-08T15:28:55.465988+00:00 app[web.1]: Parameters: {"id"=>"edit"}
2014-05-08T15:28:55.466009+00:00 app[web.1]: Parameters: {"id"=>"edit"}
2014-05-08T15:28:55.469914+00:00 app[web.1]: Completed 404 Not Found in 4ms
2014-05-08T15:28:55.469922+00:00 app[web.1]: Completed 404 Not Found in 4ms
2014-05-08T15:28:55.470930+00:00 app[web.1]:
2014-05-08T15:28:55.470933+00:00 app[web.1]: ActiveRecord::RecordNotFound (Couldn't find Order without an ID):
2014-05-08T15:28:55.470935+00:00 app[web.1]: app/controllers/orders_controller.rb:69:in `set_order'
2014-05-08T15:28:55.470938+00:00 app[web.1]:
2014-05-08T15:28:55.470937+00:00 app[web.1]:
2014-05-08T15:28:55.470943+00:00 app[web.1]:
2014-05-08T15:28:55.470945+00:00 app[web.1]: ActiveRecord::RecordNotFound (Couldn't find Order without an ID):
2014-05-08T15:28:55.470946+00:00 app[web.1]: app/controllers/orders_controller.rb:69:in `set_order'
2014-05-08T15:28:55.470948+00:00 app[web.1]:
2014-05-08T15:28:55.470949+00:00 app[web.1]:
So, in ActiveRecord if you have a custom primary key you need to specify it in the model
class Order
self.primary_key = :order_id
Docs: http://guides.rubyonrails.org/active_record_basics.html#overriding-the-naming-conventions

Solr on heroku does not work

I have just deployed my app on Heroku. I have access to home however when I create an account I have the error "we're sorry but something were wrong". In the heroku console there are the following lines :
2013-07-25T14:43:57.205734+00:00 app[web.1]:
2013-07-25T14:43:57.326077+00:00 app[web.1]:
2013-07-25T14:43:57.326077+00:00 app[web.1]: app/controllers/users_controller.rb:36:in `create'
2013-07-25T14:43:57.326077+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - {:data=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">User 23</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"nom_text\">julien</field><field name=\"email_text\">julien#resenders.com</field></doc></add>", :headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :path=>"update", :uri=>#<URI::HTTP:0x007f987b4c48a0 URL:http://localhost:8080/solr/update?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}):
2013-07-25T14:43:57.337273+00:00 app[web.1]: Processing by UsersController#create as HTML
2013-07-25T14:43:57.326077+00:00 app[web.1]:
2013-07-25T14:43:57.326077+00:00 app[web.1]:
2013-07-25T14:43:57.337273+00:00 app[web.1]: Completed 500 Internal Server Error in 850ms
2013-07-25T14:43:57.337273+00:00 app[web.1]: Parameters: {"utf8"=>"???", "authenticity_token"=>"gdLt0F1TJi+GaFCe8sFFKRikXgAEEnW6DmIyPbLeCa4=", "user"=>{"nom"=>"julien", "email"=>"julien#resenders.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "resender"=>"0", "gang_id"=>"1", "addresses_attributes"=>{"0"=>{"first_name"=>"L", "last_name"=>"L"}}}, "commit"=>"Inscription"}
2013-07-25T14:43:57.337273+00:00 app[web.1]: Rendered devise/mailer/confirmation_instructions.html.erb (1.3ms)
2013-07-25T14:43:57.344954+00:00 heroku[router]: at=info method=POST path=/users host=www.resenders.com fwd="37.58.138.20" dyno=web.1 connect=4ms service=930ms status=500 bytes=643
I figured out the problem in local with "rake sunspot:solr:run" but even if "heroku run rake sunspot:solr:run" seems to work, it does not sort out this trouble on Heroku. How can I do ? Maybe with Websolr ? Thank you in advance guys !
4 Suggestions:
Be sure that your server is running
Be sure that your routes are set correctly
Add the websolr add on to your heroku stack --> https://devcenter.heroku.com/articles/websolr
Be sure to always remove personal data when pasting code to the internet

Config Tire to work with Bonsai ElasticSearch Heroku add-on

So I have a rails 3.2 app. I created an index.
I followed this guide: https://gist.github.com/nz/2041121 to create an bonsai.rb file in config/initializers/bonsai.rb
It looks like this:
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
# Optional, but recommended: use a single index per application per environment.
# Caveat: This convention not be entirely supported throughout Tire's API.
app_name = Rails.application.class.parent_name.underscore.dasherize
app_env = Rails.env
INDEX_NAME = "#{app_name}-#{app_env}"
But I dosent work, this outprint from the heroku logs:
2013-03-06T17:04:54+00:00 app[web.1]: Processing by SchoolsController#index as HTML
2013-03-06T17:04:54+00:00 app[web.1]: Started GET "/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6" for 192.165.96.102 at 2013-03-06 17:04:54 +0000
2013-03-06T17:04:54+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "query"=>"Malmö"}
2013-03-06T17:04:58+00:00 heroku[router]: at=info method=GET path=/trafikskola?utf8=%E2%9C%93&query=Malm%C3%B6 host=stormy-escarpment-2346.herokuapp.com fwd="192.165.96.102" dyno=web.1 queue=0 wait=0ms connect=1ms service=3106ms status=500 bytes=643
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]: app/models/school.rb:19:in `search'
2013-03-06T17:04:58+00:00 app[web.1]: app/controllers/schools_controller.rb:10:in `index'
2013-03-06T17:04:58+00:00 app[web.1]: Completed 500 Internal Server Error in 3073ms
2013-03-06T17:04:58+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
2013-03-06T17:04:58+00:00 app[web.1]:
2013-03-06T17:04:58+00:00 app[web.1]:
My questions:
Should I put somehting in the ELASTICSEARCH_URL in the bonsai.rb file? If yes, then what?
I have created a local index to, does that mean something?
Or is it something else?
The config/initializers/bonsai.rb was right and the problem was I had to index it in production mode also.
So I did this:
heroku rake environment tire:import CLASS=School FORCE=true
And it worked.

Resources