I am writing my first ever ruby on rails app.
Locally its great, I can visit localhost:3000/ and get the default landing page, and I can visit /users to interact with a scaffold object called User.
I am using postgresql for my db and this again works locally.
I want to deploy this project to heroku. I make sure git is pushed to heroku, which it is, I also ran heroku addons:add heroku-postgresql:development and i also run heroku run rake db:migrate which completes with no output.
When I visit my applications URL I see nothing :https://whats-on-today.herokuapp.com/ Heroku logs shows a http 404:
2014-12-02T17:03:48.311284+00:00 heroku[router]: at=info method=GET path="/" host=whats-on-today.herokuapp.com request_id=fcb9cc27-e5eb-4760-bc30-8a72fe2f0bbc fwd="195.212.29.67" dyno=web.1 connect=1ms service=10ms status=404 bytes=1829
I am not sure why I can access the root url http://localhost:3000/ locally no problem, on deployment to heroku I see nothing? There is nothing much of use in the logs other than the 404. What is my deployed http path? Surely this should work if it works locally?
Can somebody please help?
You did not define a root route. Try something like this in routes.rb
root 'welcome#index'
(The page welcome/index needs to exist obviously).
Your application is deployed correctly as https://whats-on-today.herokuapp.com/users clearly shows.
Related
I have the logs and one error at the bottom I have tried rake db migrate. which didn't work either.
2017-01-28T17:08:44.257358+00:00 heroku[router]: at=info method=POST path="/sign_in" host=www.pointsonpaper.com request_id=17ca7be4-c859-47ba-b680-fc1d13a2aaaf fwd="104.57.187.118" dyno=web.1 connect=0ms service=690ms status=500 bytes=906
eo you have a rails app deployed on heroku? If so,
well on heroku you should run
heroku run rake db:migrate
However, to be more precise you should show your logs.
Run heroku logs in your terminal and post the actual error here.
I am using rails 4.1.8, ruby 2.1.1, heroku toolbelt 3.17.1
In rails I've written a method that returns random rows from the db (postgres) that meet certain parameters:
elsif f == 'random'
(Piece.all - current_user.followed_pieces - current_user.pieces).sample(10)
This method functions properly in development. In deployment, when this method is triggered Heroku returns a 500 internal server error with altogether unhelpful logs:
2014-12-08T18:28:22.628654+00:00 heroku[router]: at=info method=GET path="/api/pieces?filter=random"
host=sheltered-castle-3185.herokuapp.com request_id=88107b5e-45f6-4d44-8c3c-9b91c18411f2
fwd="67.174.254.226" dyno=web.1 connect=6ms service=90ms status=500 bytes=330
I've migrated the database and in production.rb my config.log_level = :debug, no other pages or methods on the webapp trigger a server error.
I have an app that works locally but does does not work right on heroku. The root page loads, but when I try the submit link, Heroku gives me "We're sorry, but something went wrong.
If you are the application owner check the logs for more information."
Looking at the logs, its seems like an asset issue and ive run "RAILS_ENV=production bundle exec rake assets:precompile" but I still get these log errors.
2014-09-22T01:09:39.694028+00:00 app[web.1]: [2014-09-22 01:09:39] INFO WEBrick 1.3.1
2014-09-22T01:09:39.694047+00:00 app[web.1]: [2014-09-22 01:09:39] INFO ruby 2.0.0 (2014- 09-19) [x86_64-linux]
2014-09-22T01:09:39.694487+00:00 app[web.1]: [2014-09-22 01:09:39] INFO WEBrick::HTTPServer#start: pid=2 port=24344
2014-09-22T01:09:39.797519+00:00 heroku[web.1]: State changed from starting to up
2014-09-22T01:09:40.724903+00:00 heroku[router]: at=info method=GET path="/" host=findmegnar.herokuapp.com request_id=502f7e98-22da-4825-ad85-77606ab64cca fwd="54.162.73.140" dyno=web.1 connect=2ms service=130ms status=200 bytes=1907
2014-09-22T01:09:44.875965+00:00 heroku[router]: at=info method=GET path="/" host=findmegnar.herokuapp.com request_id=900ca4d9-db6c-4c53-aeb4-f6e50c0a7e4f fwd="74.95.112.118" dyno=web.1 connect=0ms service=16ms status=304 bytes=733
2014-09-22T01:09:44.978618+00:00 heroku[router]: at=info method=GET path="/assets/application-cb25950d0e442f07f1fa7be553c321c3.css" host=findmegnar.herokuapp.com request_id=13b510e0-f3c8-4f1a-8a29-9d99a30fb794 fwd="74.95.112.118" dyno=web.1 connect=1ms service=9ms status=404 bytes=1829
2014-09-22T01:09:44.987883+00:00 heroku[router]: at=info method=GET path="/assets/application-433aac58cfba85b04e81533418015cc6.js" host=findmegnar.herokuapp.com request_id=2cbaa67e-646e-4faf-adee-c9c4606fe662 fwd="74.95.112.118" dyno=web.1 connect=0ms service=6ms status=404 bytes=1829
2014-09-22T01:09:47.967521+00:00 heroku[router]: at=info method=POST path="/searches" host=findmegnar.herokuapp.com request_id=2948d744-102f-420b-a856-63a55ab3e0c5 fwd="74.95.112.118" dyno=web.1 connect=1ms service=16ms status=500 bytes=1754
Edit: Further work found that this error was caused by lack of database. Running
heroku run rake db:reset
Fixed that issue. However, running
heroku run rake import:resorts
Did a rake import of the data I wanted to add to the data but did not actually add the data to the db.
Does anyone know if there is a special way to do rake tasks in heroku?
Heroku
If you're loading your database on Heroku again, you'll probably be best using the rake db:schema:load task - this builds the database from your schema, instead of your migrations.
#db/schema.rb
# If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch
To access Heroku functionality from your development command-line, you'll be best making use of the Heroku Toolbelt -
$ heroku run rake db:schema:load
$ heroku run ...
This enables you to perform Heroku actions from your development (local) machine. It routes your request through the Heroku API, allowing you to perform requests on the Heroku command-line as required
Errors
If you're experiencing errors on Heroku, just as some information, you'll be best looking at how they work, and appreciating how to resolve them.
There are two types of error with Heroku:
Heroku
These are caused by your application not opening on Heroku itself
The problem here is that Heroku will have a certain set of "dependencies" which are required to run your application. These dependencies are in the form of the likes of your database, files, add-ons, ENV variables, etc.
If you don't have any of these available to your app, for whatever reason, you'll end up receiving the "platform" error as mentioned above. The fix for this is purely with Heroku - you need to ensure you have the files, settings & add-ons required to get your app working correctly
-
Rails
Rails errors are specific to your application, and are likely a result of bad syntax inside your application. The distinction here is that the platform error is going to be caused by Heroku, whilst the Rails error is going to be caused by your app.
If you're seeing the above error, the simplest way to resolve it is to locate the following file & change it temporarily:
#config/environments/production.rb
config.consider_all_requests_local = true # false
By pushing this to Heroku again, you'll be able to see the errors you had on your application through the standard Rails error-handling interface
I am using devise gem with rails for authentication, my application is running fine locally but the devise views are not accessible when deploying on heroku.
Checking the log gives me following error:
←[app[web.1]:←[0m Processing by Devise::SessionsController#new as HTML
←[app[web.1]:←[0m Processing by Devise::SessionsController#new as HTML
←[app[web.1]:←[0m Completed 500 Internal Server Error in 4ms
←[heroku[router]:←[0m at=info method=GET path=/favicon.ico host=clickive.herokuapp.com request_id=739b163c-d2b3-493c-8cfa-ffabc454f468 fwd="148.88.244.110" dyno=web.1 connect=1ms service=5ms status=200 by tes=228
Can anyone help please...
i had similar issue make sure you add to your Gemfile:
gem 'bcrypt-ruby'
and then hit bundle install and push to heroku once more.
I checked the log and found that i had forgot to run AddUsernametoUsers migration on the production database.
I have a ruby on rails app on Heroku, its been there for while with one dyno ( kinda experminetation project ).
Today I changed some text entries in one of the files under views. started the server locally and got it ti run, did a push to heroku and all of the sudden after that push Heroku stopped working. Running heroku logs I get this
013-06-15T22:09:30.344294+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path=/" dyno= connect= service= status=503 bytes=
So I login to heroku to see whats the matter, I notice I don't have any dynos available for this app. After some googling I got some results to add a dyno using this command
heroku ps:scale web=1
Scaling web dynos... failed
! No such type as web.
But the message coming back was that no such type as web!!
What did I do wrong? All the edit I did was some text ( its my blog ).
PS :
I don't have a procfile, and I checked on my git history and I never did have a Procfile, and this has worked before.
ok so I found the answer,
Basically I had to add a Procfile ( still don't know why because my app was working before without one ), and in that procfile I do
web: bundle exec unicorn -p $PORT -E $RACK_ENV
Heroku recommends this approach for production apps.
link to heroku article
https://devcenter.heroku.com/articles/rails3#deploy-your-application-to-heroku