Rails 4 on Heroku with 'protected_attributes' gem - ruby-on-rails

I don't know where else to turn with this: I have spent many hours on my project, a recruiting events website for college students, but have reached quite the impasse.
In short, I plodded along in localhost - adding components like Devise; Omniauth authentication via providers Facebook, LinkedIn, and Google - building a website I was proud of along the way. Everything appeared to be working just fine, but once I pushed to 'heroku master' things started breaking big time.
I think the issues are most likely in or around:I have an Authentication model to keep track of a single user's authentication providers, alongside the User model (where all the oauth code is kept).
Without further ado, here is my app's heroku domain and my code:
http://lit-everglades-7633.herokuapp.com/
https://gist.github.com/mecampbellsoup/6357855
The things breaking which I suspect are related:
'heroku run rake db:seed' following 'pg:reset' & 'rake db:migrate'... instead of seeding with the contents of the seed file itself, a single blank Event and Company are created; more on this below
the routing and action relating to the omniauth request seems to be working just fine, according to the heroku logs (below) but no user nor authentication is actually created:
when, after resetting postgres db, I try to run 'heroku run rake db:create' or 'db:setup' I am whined at as follows:
☁ duke_recruits [master] heroku run rake db:setup
Running rake db:setup attached to terminal... up, run.5886
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
also, 'heroku run rake db:seed' appears to be doing its thing, but then my db only has 1 empty Event and 1 empty Company:
☁ duke_recruits [master] heroku run rake db:seed
Running rake db:seed attached to terminal... up, run.1767
☁ duke_recruits [master] heroku run rails c
Running rails c attached to terminal... up, run.6135
Event.allLoading production environment (Rails 4.0.0)
irb(main):001:0> Event.all
=> #ActiveRecord::Relation [#Event id: 1, title: nil, location: nil, description: nil, date: nil, end_date: nil, company_id: nil, created_at: "2013-08-27 19:30:06", updated_at: "2013-08-27 19:30:06"]
irb(main):002:0> Company.all
=> #ActiveRecord::Relation [#Company id: 1, name: nil, description: nil, website: nil, logo: nil, created_at: "2013-08-27 19:30:06", updated_at: "2013-08-27 19:30:06"]
Logs (upon opening the app on heroku and trying google authentication):
2013-08-27T19:49:18.701285+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:18 +0000
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Rails 4.0.0 application starting in production on http://0.0.0.0:49710
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Booting WEBrick
2013-08-27T19:49:18.701019+00:00 app[web.1]: => Run `rails server -h` for more startup options
2013-08-27T19:49:18.701019+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:18 +0000
2013-08-27T19:49:19.131115+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=2ms service=442ms status=304 bytes=0
2013-08-27T19:49:19.221284+00:00 heroku[router]: at=info method=GET path=/assets/application-b44a43097f814ac98347f6802323e25f.js host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=12ms status=304 bytes=0
2013-08-27T19:49:49.440894+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:49 +0000
2013-08-27T19:49:49.440894+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:49:49 +0000
2013-08-27T19:49:49.515520+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=2ms service=80ms status=304 bytes=0
2013-08-27T19:50:48.534099+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:50:48 +0000
2013-08-27T19:50:48.534099+00:00 app[web.1]: Started GET "/" for 68.175.76.48 at 2013-08-27 19:50:48 +0000
2013-08-27T19:50:48.575279+00:00 heroku[router]: at=info method=GET path=/ host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=51ms status=304 bytes=0
2013-08-27T19:50:52.293922+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:50:52 +0000
2013-08-27T19:50:52.293922+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:50:52 +0000
2013-08-27T19:50:52.591752+00:00 heroku[router]: at=info method=GET path=/users/sign_up host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=1ms service=307ms status=304 bytes=0
2013-08-27T19:51:00.368352+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368352+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.368926+00:00 app[web.1]: I, [2013-08-27T19:51:00.368823 #2] INFO -- omniauth: (google_oauth2) Request phase initiated.
2013-08-27T19:51:00.392262+00:00 heroku[router]: at=info method=GET path=/users/auth/google_oauth2 host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=3ms service=33ms status=302 bytes=469
2013-08-27T19:51:00.715597+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.715597+00:00 app[web.1]: Started GET "/users/auth/google_oauth2" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.716822+00:00 app[web.1]: I, [2013-08-27T19:51:00.716706 #2] INFO -- omniauth: (google_oauth2) Request phase initiated.
2013-08-27T19:51:00.997866+00:00 app[web.1]: Started GET "/users/auth/google_oauth2/callback?state=40ecfd10739cb874b5c461fc00cfd72ec4fcb694ef3a6878&code=4/D_(omitted_for_security)_GBlmiYhY(partially_omitted)E9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.997866+00:00 app[web.1]: Started GET "/users/auth/google_oauth2/callback?state=10739cb874b5c461fc00cfd72ec4fcb694ef3a6878&code=4/D_GBlmiYhY1rCvgdgE9yth.QpxI3jdcGpYYshQV0ieZDAoQOqyCgQI" for 68.175.76.48 at 2013-08-27 19:51:00 +0000
2013-08-27T19:51:00.998508+00:00 app[web.1]: I, [2013-08-27T19:51:00.998379 #2] INFO -- omniauth: (google_oauth2) Callback phase initiated.
2013-08-27T19:51:02.188467+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.188467+00:00 app[web.1]: Started GET "/users/sign_up" for 68.175.76.48 at 2013-08-27 19:51:02 +0000
2013-08-27T19:51:02.234644+00:00 heroku[router]: at=info method=GET path=/users/sign_up host=lit-everglades-7633.herokuapp.com fwd="68.175.76.48" dyno=web.1 connect=9ms service=52ms status=304 bytes=0
Please let me know what questions you have for me and if I can clarify anything at all. I really appreciate your time & help SO!

After a pg:reset, you can run the create command, but it usually gives you output like:
slkdjfs0dslkd already exists
So then you'll know that your database is created and ready to be used. Before you can seed though make sure you migrate. Just the standard heroku way
heroku run rake db:migrate
Then seed as normal
heroku run rake db:seed

Related

Heroku Twitter api app deployment with Rails

I am new to Ruby and Rails in general and am following this series
https://gorails.com/episodes/rails-for-beginners-part-38-deploying-to-heroku
I have this weird issue where is everything seems to work fine except connecting my app with
Twitter Api.
I did everything to connect successfully but nothing seems working!
I added the website link to Twitter developer callbacks urls which are
https://jadwlh.herokuapp.com/
along with
https://jadwlh.herokuapp.com/auth/twitter/callback
I added both
API_KEY
and
API_SECRET
to Config Vars.
I even changed SECRET_KEY_BASE in Config Vars
to the one provided in the credentials file in my app!
Even though tried everything, still got this message shown in the image below when I try to
connect my app with Twitter Api
routes.rb file
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
#GET /about
get "about", to: "about#index"
get "password", to: "passwords#edit", as: :edit_password
patch "password", to: "passwords#update"
get "sign_up", to: "registrations#new"
post "sign_up", to: "registrations#create"
delete "logout", to: "sessions#destroy"
get "sign_in", to: "sessions#new"
post "sign_in", to: "sessions#create"
get "password/reset", to: "password_resets#new"
post "password/reset", to: "password_resets#create"
get "password/reset/edit", to: "password_resets#edit"
patch "password/reset/edit", to: "password_resets#update"
get "/auth/twitter/callback", to: "omniauth_callbacks#twitter"
resources :twitter_accounts
resources :tweets
# get "/", to: "main#index"
root to: "main#index"
end
Application logs
2021-05-31T06:15:04.415968+00:00 app[web.1]: [13f44544-8fd2-4348-8b08-1191ad53716b]
2021-05-31T06:15:04.418156+00:00 heroku[router]: at=info method=HEAD path="/auth/failure?message=session_expired&strategy=twitter" host=jadwlh.herokuapp.com request_id=13f44544-8fd2-4348-8b08-1191ad53716b fwd="217.182.175.162" dyno=web.1 connect=0ms service=3ms status=404 bytes=180 protocol=https
2021-05-31T06:15:31.243002+00:00 app[web.1]: I, [2021-05-31T06:15:31.242901 #4] INFO -- : [c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8] Started POST "/auth/twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.243645+00:00 app[web.1]: D, [2021-05-31T06:15:31.243583 #4] DEBUG -- omniauth: (twitter) Request phase initiated.
2021-05-31T06:15:31.388564+00:00 app[web.1]: E, [2021-05-31T06:15:31.388453 #4] ERROR -- omniauth: (twitter) Authentication failure! 400 Bad Request: OAuth::Unauthorized, 400 Bad Request
2021-05-31T06:15:31.390962+00:00 heroku[router]: at=info method=POST path="/auth/twitter" host=jadwlh.herokuapp.com request_id=c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8 fwd="46.152.103.96" dyno=web.1 connect=1ms service=150ms status=302 bytes=834 protocol=https
2021-05-31T06:15:31.574904+00:00 heroku[router]: at=info method=GET path="/auth/failure?message=400+Bad+Request&strategy=twitter" host=jadwlh.herokuapp.com request_id=3adfd6f0-58b9-47c3-ab04-017161a56e18 fwd="46.152.103.96" dyno=web.1 connect=1ms service=6ms status=404 bytes=1902 protocol=https
2021-05-31T06:15:31.571195+00:00 app[web.1]: I, [2021-05-31T06:15:31.571067 #4] INFO -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18] Started GET "/auth/failure?message=400+Bad+Request&strategy=twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.572790+00:00 app[web.1]: F, [2021-05-31T06:15:31.572717 #4] FATAL -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18]
2021-05-31T06:15:31.572791+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18] ActionController::RoutingError (No route matches [GET] "/auth/failure"):
2021-05-31T06:15:31.572792+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18]
Thank you: )
I found the solution.
It just was copying master.key and replace it as it says below!
heroku config:set RAILS_MASTER_KEY="copy and paste here config/master.key "
How to get rails master.key after upgrading to rails 5.2

Using RSpotify Gem and Spotify is including a query sting in URI which makes it an unapproved source, rails, heroku

So I'm using the RSpotify to have users approve our app and then redirect to our site. The problem is that when Spotify redirects it is including a query string. This is throwing it off and it thinks that the URI is not an approved source.
Everything was working until I put my site up on heroku.
Here is the error:
+00:00 app[web.1]: I, [2020-02-17T12:09:24.460751 #4] INFO -- omniauth: (spotify) Request phase initiated.
2020-02-17T12:09:24.464829+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=cf73be87-9844-4b18-ba0b-518e4046676a fwd="47.17.47.4" dyno=web.1 connect=1ms service=4ms status=302 bytes=1463 protocol=http
2020-02-17T12:09:24.663083+00:00 heroku[router]: at=info method=GET path="/auth/spotify/callback?code=AQArRuRXYD_gebJVlU1Ljht_4XDFr_1dAAqlI-20Tq5504JFdP92MpRIDoNFVvBpS4xPPAqrdAJlooCTZA3yLPeUFKk5W1SE9KkLFsDp--1tIm2Vt2Y6_jrNWmDsBvWvBkuSlBbXaBW5gti8sbIHlMCHXt8MDP82l2BTduVDgjStbSuFt8SoWo8BLeYT8pc68LUs7eFqoJoww-ywkc0gLz1V7tzpEkOkn6I8N7-LRTr9cXQt_kJfQdnpsbiQ0KSn2g&state=2d5bbf3deccf88d92d68f5022475522564622cfc77104794" host=www.themixtapeproj.com request_id=f8ef1adc-0693-4ab5-bf63-f23b63b3ee1b fwd="47.17.47.4" dyno=web.1 connect=1ms service=50ms status=302 bytes=769 protocol=http
2020-02-17T12:09:24.612879+00:00 app[web.1]: I, [2020-02-17T12:09:24.612791 #4] INFO -- : [f8ef1adc-0693-4ab5-bf63-f23b63b3ee1b] Started GET "/auth/spotify/callback?code=AQArRuRXYD_gebJVlU1Ljht_4XDFr_1dAAqlI-20Tq5504JFdP92MpRIDoNFVvBpS4xPPAqrdAJlooCTZA3yLPeUFKk5W1SE9KkLFsDp--1tIm2Vt2Y6_jrNWmDsBvWvBkuSlBbXaBW5gti8sbIHlMCHXt8MDP82l2BTduVDgjStbSuFt8SoWo8BLeYT8pc68LUs7eFqoJoww-ywkc0gLz1V7tzpEkOkn6I8N7-LRTr9cXQt_kJfQdnpsbiQ0KSn2g&state=2d5bbf3deccf88d92d68f5022475522564622cfc77104794" for 47.17.47.4 at 2020-02-17 12:09:24 +0000
2020-02-17T12:09:24.613242+00:00 app[web.1]: I, [2020-02-17T12:09:24.613191 #4] INFO -- omniauth: (spotify) Callback phase initiated.
2020-02-17T12:09:24.659971+00:00 app[web.1]: E, [2020-02-17T12:09:24.659789 #4] ERROR -- omniauth: (spotify) Authentication failure! invalid_credentials: OAuth2::Error, invalid_grant: Invalid redirect URI
2020-02-17T12:09:24.659978+00:00 app[web.1]: {"error":"invalid_grant","error_description":"Invalid redirect URI"}
2020-02-17T12:09:24.765658+00:00 app[web.1]: I, [2020-02-17T12:09:24.765530 #4] INFO -- : [bdbf5819-3907-42ba-9d02-6c32137425b5] Started GET "/auth/failure?message=invalid_credentials&origin=http%3A%2F%2Fwww.themixtapeproj.com%2Fmixtapes%2F4&strategy=spotify" for 47.17.47.4 at 2020-02-17 12:09:24 +0000
2020-02-17T12:09:24.766489+00:00 app[web.1]: F, [2020-02-17T12:09:24.766404 #4] FATAL -- : [bdbf5819-3907-42ba-9d02-6c32137425b5]
From what I understand it is the query string that is throwing it off. Since I have approved http://www.themixtapeproj.com/auth/spotify/callback
So what do I have to do to get this working?
EDIT: here is the authorize part (appears before the above error):
2020-02-17T15:41:52.150535+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=2092bd50-787f-4f4f-a3a5-47e8ed29c171 fwd="100.38.116.113" dyno=web.1 connect=0ms service=15ms status=302 bytes=1451 protocol=http
2020-02-17T15:41:52.032671+00:00 heroku[router]: at=info method=GET path="/auth/spotify" host=www.themixtapeproj.com request_id=43b76294-4e0b-4137-9c40-ef0d132d97ed fwd="100.38.116.113" dyno=web.1 connect=13ms service=66ms status=302 bytes=1457 protocol=http
2020-02-17T15:41:52.005375+00:00 app[web.1]: I, [2020-02-17T15:41:52.005256 #4] INFO -- : [43b76294-4e0b-4137-9c40-ef0d132d97ed] Started GET "/auth/spotify" for 100.38.116.113 at 2020-02-17 15:41:52 +0000
2020-02-17T15:41:52.005965+00:00 app[web.1]: I, [2020-02-17T15:41:52.005846 #4] INFO -- omniauth: (spotify) Request phase initiated.
2020-02-17T15:41:52.140507+00:00 app[web.1]: I, [2020-02-17T15:41:52.140388 #4] INFO -- : [2092bd50-787f-4f4f-a3a5-47e8ed29c171] Started GET "/auth/spotify" for 100.38.116.113 at 2020-02-17 15:41:52 +0000 ```
Rails.application.config.middleware.use OmniAuth::Builder do
spotify_key = ENV['SPOTIFY_KEY']
spotify_secret = ENV['SPOTIFY_SECRET']
provider :spotify, spotify_key, spotify_secret, scope: 'playlist-modify-public'
end
def spotify
spotify_user = RSpotify::User.new(request.env['omniauth.auth'])
session[:spotify_user] = spotify_user.to_hash
redirect_to spotify_landing_path
end

Cant get MongoLab database to work on heroku

I have deployed my app to heroku but and I can see the app but the app is NOT accessing the mongolab database. I have tried resetting the database in console with
$ heroku run rake db:reset
but I get this error.
failed with error 13: "not authorized on ENV['MONGOID_DATABASE'] to execute command { dropDatabase: 1 }"
See https://github.com/mongodb/mongo/blob/master/docs/errors.md
Not sure what I am doing wrong, I have not setup an app with mongoid on heroku before, this is my first time
-UPDATE-
Here is the end of the log I have that seems to show the post is not working.
$ heroku logs
2015-09-25T16:20:15.770927+00:00 heroku[router]: at=info method=POST path="/managers" host=beta.herokuapp.com request_id=95709038-02e9-45b1-8300-0aebc287f6c1 fwd="162.239.42.196" dyno=web.1 connect=0ms service=178ms status=500 bytes=1480
2015-09-25T16:20:15.770408+00:00 app[web.1]: D, [2015-09-25T16:20:15.770342 #3] DEBUG -- : MOPED: 10.152.165.9:29821 QUERY database=ENV['MONGOID_DATABASE'] collection=managers selector={"email"=>"sample#email.com"} flags=[] limit=-1 skip=0 batch_size=nil fields={:_id=>1} runtime: 1.0352ms
Here are the router logs...
$ heroku logs --ps router
2015-09-25T20:40:46.935184+00:00 heroku[router]: at=info method=POST path="/managers" host=beta.herokuapp.com request_id=c1673463-a69f-4111-bd4d-01fdb5516ad0 fwd="162.239.42.196" dyno=web.1 connect=2ms service=109ms status=500 bytes=1480
2015-09-25T20:40:47.285029+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=beta.herokuapp.com request_id=1e998283-b02b-4cc5-83f6-7996a6991531 fwd="162.239.42.196" dyno=web.1 connect=1ms service=2ms status=200 bytes=143
2015-09-26T04:45:32.833599+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=beta.herokuapp.com request_id=59ccc2e7-18d4-4c08-8b08-a653f5d11714 fwd="2602:30a:2ef2:ac40:acb1:9144:79b4:affb,66.249.88.51" dyno=web.1 connect=1ms service=4ms status=200 bytes=143
I also see it failing to query the database
2015-09-26T05:03:39.852170+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"WVGY+XLD...A=", "manager"=>{"name"=>"Blah Blah", "company"=>"Blah Blah CO.", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
2015-09-26T05:03:40.138442+00:00 app[web.1]: D, [2015-09-26T05:03:40.138321 #3] DEBUG -- : MOPED: 10.152.165.9:29821 COMMAND database=admin command={:ismaster=>1} runtime: 23.5306ms
2015-09-26T05:03:40.146776+00:00 app[web.1]: Completed 500 Internal Server Error in 294ms
2015-09-26T05:03:40.146782+00:00 app[web.1]: Completed 500 Internal Server Error in 294ms
2015-09-26T05:03:40.152205+00:00 app[web.1]:
2015-09-26T05:03:40.152208+00:00 app[web.1]: Moped::Errors::QueryFailure (The operation: #<Moped::Protocol::Query
2015-09-26T05:03:40.152209+00:00 app[web.1]: #length=112
2015-09-26T05:03:40.152211+00:00 app[web.1]: #request_id=4
2015-09-26T05:03:40.152212+00:00 app[web.1]: #response_to=0
2015-09-26T05:03:40.152214+00:00 app[web.1]: #op_code=2004
2015-09-26T05:03:40.152215+00:00 app[web.1]: #flags=[]
2015-09-26T05:03:40.152216+00:00 app[web.1]: #full_collection_name="ENV['MONGOID_DATABASE'].managers"
2015-09-26T05:03:40.152218+00:00 app[web.1]: #skip=0
2015-09-26T05:03:40.152219+00:00 app[web.1]: #limit=-1
2015-09-26T05:03:40.152222+00:00 app[web.1]: #selector={"email"=>"sample#email.com"}
2015-09-26T05:03:40.152224+00:00 app[web.1]: #fields={:_id=>1}>
2015-09-26T05:03:40.152225+00:00 app[web.1]: failed with error 13: "not authorized for query on ENV['MONGOID_DATABASE'].managers"
2015-09-26T05:03:40.152227+00:00 app[web.1]:
2015-09-26T05:03:40.152228+00:00 app[web.1]: See https://github.com/mongodb/mongo/blob/master/docs/errors.md
I figured it out. The db was not connecting because the mongoid.yml file was incorrect. I tweaked the yml file and added the URI to the heroku variables and it worked correctly.

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.

Heroku Error? We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly heroku

Hi I wonder why one of our pages is in trouble....
I run heroku logs in our cli
And this is the output:
C:\Users\Rowell\peekboxbeta>heroku logs --app gentle-beach-4013
2012-07-13T03:41:40+00:00 app[web.12]:
2012-07-13T03:41:40+00:00 app[web.12]: ActionController::RoutingError (No route matches [GET] "/users/assets/pb/f
avicon.jpg"):
2012-07-13T03:41:40+00:00 app[web.12]:
2012-07-13T03:41:40+00:00 app[web.12]:
2012-07-13T03:41:40+00:00 app[web.12]:
2012-07-13T03:41:40+00:00 app[web.12]: cache: [GET /users/assets/pb/favicon.jpg] miss
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/users/assets/pb/favicon.jpg dyno=web.12 queue=0 wait
=0ms service=6ms status=404 bytes=728
2012-07-13T03:41:40+00:00 app[web.5]:
2012-07-13T03:41:40+00:00 app[web.5]:
2012-07-13T03:41:40+00:00 app[web.5]: Started GET "/assets/pb/prev-arrow.png" for 203.177.42.214 at 2012-07-13 11
:41:40 +0800
2012-07-13T03:41:40+00:00 app[web.5]: cache: [GET /assets/pb/prev-arrow.png] stale, valid, store
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/menu-bg.png dyno=web.6 queue=0 wait=0ms se
rvice=3ms status=200 bytes=2835
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/bird.png dyno=web.2 queue=0 wait=0ms servi
ce=4ms status=200 bytes=1833
2012-07-13T03:41:40+00:00 app[web.2]: Started GET "/assets/pb/bird.png" for 203.177.42.214 at 2012-07-13 11:41:40
+0800
2012-07-13T03:41:40+00:00 app[web.2]:
2012-07-13T03:41:40+00:00 app[web.2]:
2012-07-13T03:41:40+00:00 app[web.2]: cache: [GET /assets/pb/bird.png] stale, valid, store
2012-07-13T03:41:40+00:00 app[web.4]:
2012-07-13T03:41:40+00:00 app[web.4]:
2012-07-13T03:41:40+00:00 app[web.4]: Started GET "/assets/pb/twitter_32.png" for 203.177.42.214 at 2012-07-13 11
:41:40 +0800
2012-07-13T03:41:40+00:00 app[web.4]: cache: [GET /assets/pb/twitter_32.png] stale, valid, store
2012-07-13T03:41:40+00:00 app[web.11]:
2012-07-13T03:41:40+00:00 app[web.11]:
2012-07-13T03:41:40+00:00 app[web.11]: Started GET "/assets/pb/bottom-shadow.png" for 203.177.42.214 at 2012-07-1
3 11:41:40 +0800
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/twitter_32.png dyno=web.4 queue=0 wait=0ms
service=4ms status=200 bytes=2313
2012-07-13T03:41:40+00:00 app[web.11]: cache: [GET /assets/pb/bottom-shadow.png] stale, valid, store
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/bottom-shadow.png dyno=web.11 queue=0 wait
=0ms service=6ms status=200 bytes=145
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/prev-arrow.png dyno=web.5 queue=0 wait=0ms
service=5ms status=200 bytes=1043
2012-07-13T03:41:40+00:00 app[web.9]:
2012-07-13T03:41:40+00:00 app[web.9]:
2012-07-13T03:41:40+00:00 app[web.9]: Started GET "/assets/pb/facebook_32.png" for 203.177.42.214 at 2012-07-13 1
1:41:40 +0800
2012-07-13T03:41:40+00:00 app[web.9]: cache: [GET /assets/pb/facebook_32.png] stale, valid, store
2012-07-13T03:41:40+00:00 app[web.3]:
2012-07-13T03:41:40+00:00 app[web.3]:
2012-07-13T03:41:40+00:00 app[web.3]: Started GET "/assets/pb/footer-bullet.png" for 203.177.42.214 at 2012-07-13
11:41:40 +0800
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/facebook_32.png dyno=web.9 queue=0 wait=0m
s service=18ms status=200 bytes=2094
2012-07-13T03:41:40+00:00 app[web.3]: cache: [GET /assets/pb/footer-bullet.png] stale, valid, store
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/footer-bullet.png dyno=web.3 queue=0 wait=
0ms service=21ms status=200 bytes=391
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]: Started GET "/assets/pb/menu-bg.png" for 203.177.42.214 at 2012-07-13 11:41
:40 +0800
2012-07-13T03:41:40+00:00 app[web.6]: Started GET "/assets/pb/header-glow.png" for 203.177.42.214 at 2012-07-13 1
1:41:40 +0800
2012-07-13T03:41:40+00:00 app[web.6]: cache: [GET /assets/pb/menu-bg.png] stale, valid, store
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]: cache: [GET /assets/pb/header-glow.png] stale, valid, store
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]:
2012-07-13T03:41:40+00:00 app[web.6]: Started GET "/assets/pb/twitter-border.png" for 203.177.42.214 at 2012-07-1
3 11:41:40 +0800
2012-07-13T03:41:40+00:00 app[web.6]: cache: [GET /assets/pb/twitter-border.png] stale, valid, store
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/header-glow.png dyno=web.6 queue=0 wait=0m
s service=36ms status=200 bytes=36446
2012-07-13T03:41:40+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/twitter-border.png dyno=web.6 queue=0 wait
=0ms service=37ms status=200 bytes=117
2012-07-13T03:41:41+00:00 app[web.10]:
2012-07-13T03:41:41+00:00 app[web.10]: Started GET "/assets/pb/noise.png" for 203.177.42.214 at 2012-07-13 11:41:
40 +0800
2012-07-13T03:41:41+00:00 app[web.10]:
2012-07-13T03:41:41+00:00 app[web.10]: cache: [GET /assets/pb/noise.png] stale, valid, store
2012-07-13T03:41:41+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/noise.png dyno=web.10 queue=0 wait=0ms ser
vice=957ms status=304 bytes=0
2012-07-13T03:41:41+00:00 app[web.10]:
2012-07-13T03:41:41+00:00 app[web.10]: Started GET "/assets/pb/next-arrow.png" for 203.177.42.214 at 2012-07-13 1
1:41:41 +0800
2012-07-13T03:41:41+00:00 app[web.10]:
2012-07-13T03:41:41+00:00 app[web.10]: cache: [GET /assets/pb/next-arrow.png] stale, valid, store
2012-07-13T03:41:41+00:00 heroku[router]: GET www.peekbox.tv/assets/pb/next-arrow.png dyno=web.10 queue=0 wait=0m
s service=858ms status=304 bytes=0
2012-07-13T03:41:42+00:00 app[web.8]: Started GET "/bo" for 180.194.245.32 at 2012-07-13 11:41:42 +0800
2012-07-13T03:41:42+00:00 app[web.8]:
2012-07-13T03:41:42+00:00 app[web.8]: Processing by InformationController#show as HTML
2012-07-13T03:41:42+00:00 app[web.8]: Parameters: {"username"=>"bo"}
2012-07-13T03:41:42+00:00 app[web.8]:
2012-07-13T03:41:42+00:00 app[web.8]: Rendered information/_pic.html.haml (0.9ms)
2012-07-13T03:41:42+00:00 app[web.8]: Rendered information/_d
ata.html.haml (0.5ms)
2012-07-13T03:41:42+00:00 app[web.8]: Rendered information/_controls.html.haml (6.3ms)
2012-07-13T03:41:43+00:00 app[web.8]: Rendered information/_wall_post.html.haml (1227.0ms)
2012-07-13T03:41:43+00:00 app[web.8]: Rendered information/show.html.haml within layouts/application (1236.4ms)
2012-07-13T03:41:43+00:00 app[web.8]: Completed 500 Internal Server Error in 1242ms
2012-07-13T03:41:43+00:00 app[web.8]:
2012-07-13T03:41:43+00:00 app[web.8]: ActionView::Template::Error (undefined method `profilepic' for nil:NilClass
):
2012-07-13T03:41:43+00:00 app[web.8]: 5: %div.post
2012-07-13T03:41:43+00:00 app[web.8]: 6: -#wall_posts.each do |post|
2012-07-13T03:41:43+00:00 app[web.8]: 8: -unless post.poster.profilepic == nil
2012-07-13T03:41:43+00:00 app[web.8]: 9: %div#wall-post
2012-07-13T03:41:43+00:00 app[web.8]: 7: %div
2012-07-13T03:41:43+00:00 app[web.8]: 10: %div#wall-poster-pic
2012-07-13T03:41:43+00:00 app[web.8]: 11: =link_to (image_t
ag post.poster.profilepic_url(:profile_pic) ,:style => "width:50px;height:76px"), other_user_path(post.poster.use
rname)
2012-07-13T03:41:43+00:00 app[web.8]: app/views/information/_wall_post.html.haml:8:in `block in _app_views_info
rmation__wall_post_html_haml___575386532158736245_58517160'
2012-07-13T03:41:43+00:00 app[web.8]: app/views/information/_wall_post.html.haml:6:in `_app_views_information__
wall_post_html_haml___575386532158736245_58517160'
2012-07-13T03:41:43+00:00 app[web.8]: app/views/information/show.html.haml:20:in `_app_views_information_show_h
tml_haml__598682898842295215_31999300'
2012-07-13T03:41:43+00:00 app[web.8]:
2012-07-13T03:41:43+00:00 app[web.8]:
2012-07-13T03:41:43+00:00 app[web.8]: cache: [GET /bo] miss
2012-07-13T03:41:43+00:00 heroku[router]: GET www.peekbox.tv/bo dyno=web.8 queue=0 wait=0ms service=1252ms status
=500 bytes=728
2012-07-13T03:41:43+00:00 heroku[nginx]: 180.194.245.32 - - [13/Jul/2012:03:41:43 +0000] "GET /bo HTTP/1.0" 500 7
28 "http://www.peekbox.tv/profile" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20
.0.1132.57 Safari/536.11" www.peekbox.tv
2012-07-13T03:41:44+00:00 heroku[nginx]: 180.194.245.32 - - [13/Jul/2012:03:41:44 +0000] "GET /favicon.ico HTTP/1
.0" 304 0 "-" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536
.11" www.peekbox.tv
2012-07-13T03:42:27+00:00 heroku[worker.2]: State changed from crashed to starting
2012-07-13T03:42:31+00:00 heroku[worker.2]: Starting process with command `bundle exec rake jobs:work`
2012-07-13T03:42:32+00:00 heroku[worker.2]: State changed from starting to up
2012-07-13T03:42:37+00:00 app[worker.2]: rake aborted!
2012-07-13T03:42:37+00:00 app[worker.2]: Don't know how to build task 'jobs:work'
2012-07-13T03:42:37+00:00 app[worker.2]:
2012-07-13T03:42:37+00:00 app[worker.2]: (See full trace by running task with --trace)
2012-07-13T03:42:38+00:00 heroku[worker.2]: Process exited with status 1
2012-07-13T03:42:38+00:00 heroku[worker.2]: State changed from up to crashed
C:\Users\Rowell\peekboxbeta>heroku rake db:version
WARNING: `heroku rake` has been deprecated. Please use `heroku run rake` instead.
Running `rake db:version` attached to terminal... failed
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
C:\Users\Rowell\peekboxbeta>heroku rake db:version --app gentle-beach-4013
WARNING: `heroku rake` has been deprecated. Please use `heroku run rake` instead.
Running `rake db:version` attached to terminal... up, run.1
Current version: 20120501142157
I really don't know what happened? When I'm browsing http://peekbox.tv/bo
The error still appears.
Please help me.
Should i run heroku rake db:migrate to heal the errors or any other solutions
We're totally in trouble.
The actual error is a couple of lines down:
2012-07-13T03:41:43+00:00 app[web.8]: ActionView::Template::Error (undefined method `profilepic' for nil:NilClass
You are calling profilepic on an object that is nil, with this code:
post.poster.profilepic_url(:profile_pic)
Therefore one of your post objects has a poster that is nil. Experiment in the console on Heroku (heroku run console) and see if you can find the post that doesn't have a poster.
Putting my "comment" here so the text can be formatted properly. From the terminal try:
$ heroku console
>> Post.all # gives you a list of all the posts
>> Post.first.poster # get first value in "posts" table and run "poster" method
>> Post.find(3) # get post with ID of 3
>> Post.find(3).poster # run "poster" method on post where ID = 3
This should get you started. Your error is showing that post.poster is nil and you want to find out why.
But I agree with #ryanbigg that you need to learn the basics. Judging from your experience level this might not be something you can figure out on your own.

Resources