Simple test app deploys to Heroku but won't run - ruby-on-rails

I'm new to Heroku. I tried pushing a simple test Rails 3.1.1 app to Heroku. The only changes that I made to it from the "new" Rails app template was to create a Home controller and point the root to home#index. I also ran
rails g scaffold Mark type:string start_time:datetime end_time:datetime subject:string measure:float special_event:boolean flag:boolean in_progress:boolean
so that I could run a database migration and test to make sure all showed up properly. The final change that I made was to the Gemfile, which now looks like this:
source 'http://rubygems.org'
gem 'rails', '3.1.1'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I followed the Heroku tutorial for this. The push worked, there were no errors reported. I ran heroku rake db:migrate heroku addons:add logging. I also deleted public/index.html from the app. When I run the app locally with rails server, it works fine. I also can manually navigate to the "marks" index, per the scaffold.
When I run heroku open, all I get is the standard We're sorry, but something went wrong. Rails page. heroku logs shows me nothing at all.
What am I doing wrong here? This is about as simple as test cases get, yet I can't get it to work after fiddling with it for hours, creating new apps, deleting this app and trying again, trying to deploy another app, etc.

The problem here is that Rails 3.1 asset pipeline doesn't work 'out of the box' on Bamboo-mri-1.9.2 which is the default when you do heroku create.
The solution is to do heroku create --stack cedar and then push - all will be fine then :)

Try doing this just to see if this works:
rails new stackoverflow
cd stackoverflow/
git init
git add .
git commit -m 'all'
git remote add origin git#github.com:noahc/stackoverflow.git #you'll need to change this
git push origin master
heroku create
git push heroku master
heroku open
If that doesn't work, then it is something to do with your local machine. I just ran through this and it works on my end. See: http://gentle-dawn-1050.heroku.com. If this doesn't fail, I'd try making the changes to the GemFile and see if you can get it to fail that way.

I had the same problem. Looks like you got to the bottom of your issue, but for future problem-havers I want to point out that it could be a discrepancy between the database you use for your local app and the one behind the live app. In my case, my local database was populated, and my Heroku site was empty, since l I didn't properly migrate.
This problem only became apparent when I ran "rake db:reset" in the terminal, (to clear all the data in my local app's database), after which I was able to easily find the bugs in my code.
Conclusion: if the information in your database is negligible, I would suggest clearing it and troubleshooting from there, because it could be that the site you've deployed just doesn't have data yet, and maybe your code doesn't properly handle that kind of exception.......

Related

Problem when trying to upload Rails static website to Heroku?

I am newbie with Heroku and trying to upload a static website to Heroku. Here is what I did with this one.
First, I made a static website named Y , and when I ran localhost:3000, it ran very ok.
Then I followed suggestions from internet, I changed my gemfile
gem 'sqlite3'
to
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
and, change my routes.rb file like this
Rails.application.routes.draw do
get 'home/index'
root 'home#index'
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
end
But when I tried to run heroku open , it still give me this error
Sorry for my newbie's question, but I am stucking with this one and very confusing. Could you please give me some ideas? Thank you very much.
Check your config/database.yml
You are using pg gem in production but your database.yml file is configured for sqlite3.
It's better to configure your app to use pg on both production and development as well.
You should change your gem file to use gem pg in development
Run bundle install
And then reconfigure your database.yml to use the pg database.
Then run
Rails db:create
Rails db:migrate
And dont forget to add our enviroment variables to heroku so that it can use the database.

How do I find out what the error is on heroku

On localhost my app works well even when I run it in production:
rails s -e production
However on heroku it crashes. Previously it worked. I can't find the reason because "heroku logs" doesn't show much it info, it basically says "error". What kind of error? Where exactly?
Here's my gemfile:
ruby '2.2.1'
gem 'rails', '4.2.4'
group :assets do
gem 'sass-rails'
gem 'uglifier'
end
We use LogEntries in Heroku.
They have a really good feature called "Live Tail" - allowing you to see how the server runs in real time. This gives you verbose access to all the errors etc (much better than Heroku logs):
It's totally free and allows you to monitor your dyno in "real time"; it shows the actual Rails errors too.

Active Admin Layout Not Display Proper In Production Environment

My Active Admin Layout Not Comes in Production Environment.
I added in Gemfile
gem 'activeadmin', github: 'gregbell/active_admin'
See My Active Admin Page
Help me Please.
Thanks In Advance
Im using Rails 4 and after running the server in RAILS_ENV=production i would get the same layout as you did, although it works in the development environment. after searching in the web for different answers that one that work for me was the next. Heroku does NOT compile files under assets pipelines in Rails 4 i find the answer here.
add rails_12factor to your gemfile
gem 'rails_12factor', group: :production
then
bundle install
and then restart your server
i did some modifications to config/application.rb file but it never worked for me (somthing to do with precompile assets) therefor i dont think it's necessary.
hope it helps

Local Gem Causes Heroku Push to Fail

I have a Gem on my local machine that I declare in my Gem file like this:
group :assets do
gem 'my_gem', path: "/Users/me/path/to/my_gem"
end
This works great locally, but when I push to staging on Heroku, the build fails because the gem isn't available.
Currently I'm having to comment/uncomment this gem between deploys which is a real pain.
I've also tried adding it to my development group, but this doesn't help.
Why is Heroku looking for this gem?
Bundler always needs to resolve all of the gems in your Gemfile. You shouldn't commit a Gemfile that contains a local path.
Instead, push your gem to a git repository that is reachable from Heroku and point to that in your Gemfile.
For development, you can use a local path override: http://bundler.io/v1.3/git.html#local
you can try placing the gem in vendor/gems directory, create it if it doesn't exist.then in your Gemfile do like this:
gem 'rails_multisite', path: 'vendor/gems/rails_multisite'
and make sure you run bundle update so Heroku can Pickup the changes

RailsTutorial, Micoroposts - push to Heroku not working fully

I'm following Rails Tutorial, creating a micoroposts app and pushing to Heroku. I'm able to get everything working locally, but the push to Heroku, I get no error messages, but the link myurl.heroku.com/micoroposts gives me the message, "The page you were looking for doesn't exist."
I have successfully added the following to my Gemfile (and run bundle install), per the tutorial advice, but no luck:
gem 'rails', '3.0.3'
'sqlite3-ruby', '1.3.2', :group => :development
Any ideas what might be happening?
You need to put the gem requirements on several lines:
gem 'rails', '3.0.3'
gem 'sqlite-ruby', '1.3.2'
And don't worry too much about the group => development, Heroku takes care of db connections for you.
When you did heroku create it would have told you an application name 'some-name-you-typed-in', so your url would be http://some-name-you-typed-in.heroku.com to see if the application starts.

Resources