I’ve deployed my app to Heroku however whenever I try to search for a
professor or even view an individual professor (without searching) I
just get “We’re sorry, but something went wrong.”
Running heroku logs returns:
Rendered layouts/_header.html.erb (0.7ms)
2016-06-19T00:10:42.316086+00:00 app[web.1]: Completed 200 OK in 35ms
(Views: 32.3ms | ActiveRecord: 0.9ms)
2016-06-19T00:10:46.924567+00:00 heroku[router]: at=info method=GET
path=“/professors/search?utf8=%E2%9C%93&search=test” host=professor-ratings.herokuapp.com
request_id=a69a87dd-7730-4bbb-a903-e1be1d2d5635 fwd=“198.84.185.123”
dyno=web.1 connect=1ms service=14ms status=500 bytes=1754
2016-06-19T00:10:46.927525+00:00 app[web.1]:
2016-06-19T00:10:46.926535+00:00 app[web.1]: Completed 500 Internal
Server Error in 6ms (ActiveRecord: 0.0ms)
2016-06-19T00:10:46.918438+00:00 app[web.1]: Started GET
“/professors/search?utf8=%E2%9C%93&search=test” for 198.84.185.123 at
2016-06-19 00:10:46 +0000
2016-06-19T00:10:46.927533+00:00 app[web.1]:
app/controllers/professors_controller.rb:35:in `search’
2016-06-19T00:10:46.920628+00:00 app[web.1]: Parameters: {“utf8”=>“✓”,
“search”=>“test”}
2016-06-19T00:10:46.927533+00:00 app[web.1]: Faraday::ConnectionFailed
(Connection refused - connect(2) for “localhost” port 9200):
2016-06-19T00:10:46.927534+00:00 app[web.1]:
2016-06-19T00:10:46.920585+00:00 app[web.1]: Processing by
ProfessorsController#search as HTML
2016-06-19T00:10:46.927534+00:00 app[web.1]:
I’ve seen a similar issue discussed on Stack Overflow and someone said
that elastic search may not be running. But if I run curl
localhost:9200 there is a hash so I believe it’s running and I don’t
think that’s the problem.
Any help would be greatly appreciated I’m very lost this is my first app
I’m building mostly to teach myself rails so I’ve never deployed
anything before.
I’ve deployed my app to Heroku however whenever I try to search for a
professor or even view an individual professor (without searching) I
just get “We’re sorry, but something went wrong.”
If you cannot even view an record then there it is something more than
a search problem. What does the log show when you just try to view?
Always fix the simplest problem first.
I’ve deployed my app to Heroku however whenever I try to search for a
professor or even view an individual professor (without searching) I
2016-06-19T00:10:46.920628+00:00 app[web.1]: Parameters: {“utf8”=>“✓”,
“search”=>“test”}
2016-06-19T00:10:46.927533+00:00 app[web.1]: Faraday::ConnectionFailed
(Connection refused - connect(2) for “localhost” port 9200):
I’ve seen a similar issue discussed on Stack Overflow and someone said
that elastic search may not be running. But if I run curl
localhost:9200 there is a hash so I believe it’s running and I don’t
think that’s the problem.
Wait, what?? “localhost” from your development system is not the
same as “localhost” from a Heroku-deployed application.
You need to sign up for a Heroku ElasticSearch add-on or run your
own ES instance somewhere; in either case, the access URL will
certainly not be for “localhost”
It seems to be having a problem with showing the name, I don’t know why
this is a problem this page works fine on localhost. One possible thing
I can think of is that I created a column “firstname” in a recent
migration (still well before I pushed this to Heroku) could it be
possible that Postgres is using an earlier migration then SQLite?
This is my show.hm.erb where the offending method is:
It seems to be having a problem with showing the name, I don’t know why
this is a problem this page works fine on localhost. One possible thing
I can think of is that I created a column “firstname” in a recent
migration (still well before I pushed this to Heroku) could it be
possible that Postgres is using an earlier migration then SQLite?
Have a look at the database itself and see. I don’t know how to do
that on Heroku but I am sure google will tell you if not some
documentation on Heroku.
However I note that the error is referring to fullname but you say you
added a column firstname so perhaps that is the issue.
Elasticsearch still eludes me I’ve been going through this resource: https://docs.bonsai.io/docs/ruby-on-rails trying to get bonsai to work I
get to the last step “Index your documents” but I’m not sure what to put
for “curl -XPUT http://username:[email protected]/users” is it
just my Heroku username, password and app?
presumably it’s your bonsai account information, but
per the referenced page that’s not the “last step” but only an
alternative to the preferred setting up of rake tasks.
What problem(s) are you having with the rake task approach?
So the problem displaying the record was indeed because Heroku was on an
older migration of the DB. So after migrating to the changed column
names I can access records.
Elasticsearch still eludes me I’ve been going through this resource: https://docs.bonsai.io/docs/ruby-on-rails trying to get bonsai to work I
get to the last step “Index your documents” but I’m not sure what to put
for “curl -XPUT http://username:[email protected]/users” is it
just my Heroku username, password and app? Sorry I just can’t find a lot
of resources to help me deploy Searchkick via Elasticsearch anywhere.
I’ve tried to clean it up nicely (when it was private it was a little
untidy and still is). I have those gems installed but whenever I try to
load the app in Heroku it crashes:
Exiting
2016-06-30T06:51:44.294061+00:00 app[web.1]:
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
`require’: No such file to load – easticsearch/model (LoadError)
and now whenever I view the app in localhost it also crashes:
Started GET “/professors” for ::1 at 2016-06-30 06:01:07 -0400
Processing by ProfessorsController#index as HTML
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
LoadError (cannot load such file – easticsearch/model):
Thank you so much! I’ve made those changes and pushed them to Github,
it’s working on my localhost, after work if I have time I’ll try to push
it to Heroku and see if it works.
On Monday, July 4, 2016 at 6:50:35 PM UTC+1, Ruby-Forum.com User wrote:
Then I had to reindex the DB and migrate to Heroku. Just to see if it
would work I copied that code directly from an answer on Stack Overflow
but now I’m wondering about the AWS url in the if statement, because
that works for me but I have no idea where that URL is from since I
don’t personally have an AWS account, is there another more free place
to host your Elasticsearch? By using this URL am I hijacking someone
else’s AWS’s account?
That does look like the the AWS provided elasticsearch hosting service.
If that URL is part of the copied post, then yes you are using someone
else’s elasticsearch instance (if you’re feeling helpful you could alert
whoever posted their data)