Application Error rails app on heroku - ruby-on-rails

I have uploaded my app to heroku, its a simple app to test a login, it uses a gem named sorcery, but when I test it on heroku, I get Application Error
To upload to heroku I only have do this sequence:
git init
git add .
git commit -m "init"
heroku create
heroku push heroku master
heroku rake db:migrate
I get this error:
rake aborted!
undefined method `sorcery' for
#<Rails::Application::Configuration:0x0000000266e660>
)
Please help me, I think that the gem sorcery is causing this problem, but I dont know what to do.
You can see the website here

Does this work on you localhost?
I see form your list of commands that
bundle install
is not there.
Make sure you have
gem "sorcery"
in your gem file
Then do
heroku login
and
bundle install
You'll probably get other errors. Go to Getting Started with Rails 3.x on Heroku and follow the instructions.

Related

Deploying Ruby on Rails to Heroku

I am trying to upload RoR application to Heroku.
OS - Ubuntu, ruby version - 2.2.2p95, rails version - 4.2.1, database - PostgreSQL, installed RoR via BrightBox (Tutorial from treehouse), using git push heroku master to upload.
On the local server app works fine. When I push it to heroku, it gives out an error:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
Log files say:
/usr/bin/env: ruby2.2: No such file or directory
I've tried all the possible variants, I could find on the Internet:
rake rails:update:bin
Remove bin from ~/.gitignore (But there is no such file)
heroku config:set PATH=bin:vendor/bundle/ruby/2.2.2/bin:/usr/local/bin:/usr/bin:/bin
Adding this to the GemFile: ruby '2.2.2'
Changed #!/usr/bin/env ruby2.2(.2 (not sure about ".2")) to #!/usr/bin/env ruby (in bin/rake, bin/bundle and bin/rails)
heroku run rails db:migrate
rake rails:update:bin
ln -s /usr/bin/nodejs /usr/bin/node
To upload to heroku, I've configured git, after that logged in heroku, after that "heroku create", after that "git push heroku master", then "heroku open"
And many others... Any ideas how to solve that problem?
Do you have the gem rails12_factor installed and config.assets.compile = true ?
Not sure you mistyped or something else. but heroku run rails db:migrate will not work it should be heroku run rake db:migrate . It might be because you don't have root page. Precompile issue etc.
Run heroku logs -a app_name to see actual logs.

Heroku Authentication Faulure in rails system call

I have a Rails 4.1.1 app which is hosted on heroku. Recently I changed my heroku login credentials.
In the terminal if I run for example the line:
heroku run rake db:migrate
It will successfully complete the task. "which heroku" gives: /usr/local/heroku/bin/heroku
In my Rails app I have a deploy rake task which calls the same command through system
task :staging do
...
system "heroku run rake db:migrate"
end
This however results in the error: Running 'rake db:migrate' attached to terminal... Authentication failure
In this case "which heroku" gives: /usr/local/rvm/gems/ruby-2.1.1#amn/bin/heroku
It's worth noting my app has the gem pgbackups-archive which requires the heroku gem.
How can I force the heroku gem version Rails is using to use my new login credentials or is there another way to fix this.
Thanks
The issue turned out to be with the Heroku gem.
The Heroku gem uses the user account API rather than login details. Updating the API key resolved the Authentication issue.

"No Heroku apps are configured error" on Heroku Sans

I am configuring heroku_san for deploying Rails to Heroku. When I run any rake task it creates, I keep getting this error:
rake production deploy
No heroku apps are configured. Run:
rails generate heroku:config
I know that there are Heroku apps because I can see them when I run heroku list. What might be happening? Why can't this gem find the Heroku apps?
It looks like the gem was looking for a file called ~/.heroku/credentials. I did not have it. So I created that and added my user email and password separated by a linebreak:
myemail#gmail.com
herokupassword
Worked like a charm.

Rails error 500, "We're sorry, but something went wrong"

After three evenings on this problem and reading all the posts about this, I have to ask this question finally!
I want to deploy the most simple Rails app to Heroku:
rails new test_appli
cd test_appli
git init
git add .
git commit -m "initial commit"
heroku create
git push heroku master
Everything's OK, the application works well on Heroku. After that, I'll create a SQLite3 database:
rails generate scaffold User name:string email:string
rake db:migrate
Everything's OK on the local machine. I can see localhost:3000/users well. Then I want to put the DB on Heroku. First I modify my Gemfile:
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
Then I send the whole thing to Heroku:
git init
git add .
git commit -m "with Database"
git push heroku master
heroku rake db:migrate
Then there are no errors in the batch, everything is OK, the DB is sent, but the page heroku.com/users gives the error
Rails 500, "We're sorry, but something went wrong"
I don't know more what to do. Can you help me?
I suspect you're trying to deploy a Rails 3.1 application to the bamboo stack (heroku create defaults to the 1.9.2 bamboo stack and doesn't run Rails 3.1 out of the box.). The Cedar stack is much better suited to Rails 3.1 sites -
try
heroku create --stack cedar
when creating your application on Heroku and repush it up. Also note your rake command on Heroku will become
heroku run rake db:migrate
Do:
heroku run rake db:schema:load
I had the same issue. It works for me after git push heroku master
Don't do the git init in the second set of commands - you only need to initialise your Git repo once.
Other than that this looks fine - are you seeing any errors anywhere?
Why would you use the pg gem in your production group, but the sqlite3 gem in your development group? Seems to me that your problem is likely due to the fact that you're developing with a different database then you're using in the production environment. If I were you, I would stick to one, which would make it much easier to debug.
If you really want/need to get the application running ASAP, then just run it in production with sqlite... Gemfile:
gem 'rails'
gem 'sqlite3'
Also, a quick way to figure out what the error is would be to run heroku logs from the unix console.
Which version of Rails?
Can you try creating the application running on the Cedar stack?
heroku create myapp --stack cedar
Given the application is running on cedar you need to modify the commands a bit, for example:
heroku run rake db:migrate
In any case you really need to checkout your logs, because your problem might not even be database related, but assets related.
Do you have the heroku shared 5mb database instance added?
When you create your heroku app (on cedar) it doesn't necessarily create the database automatically.
airlift:projects $ heroku create --stack cedar testapp9
Creating testapp9... done, stack is cedar
http://testapp9.herokuapp.com/ | git#heroku.com:testapp9.git
airlift:projects $ heroku addons --app testapp9
logging:basic
releases:basic
When you view your heroku config, you get nothing:
heroku config
airlift:projects $ heroku config --app testapp9
airlift:projects $
To add a database:
heroku addons:add shared-database:5mb
airlift:projects $ heroku addons:add shared-database:5mb --app testapp9
-----> Adding shared-database:5mb to testapp9... done, v3 (free)
airlift:projects $ heroku config
No app specified.
Run this command from an app folder or specify which app to use with --app <app name>
airlift:projects $ heroku config --app testapp9
DATABASE_URL => postgres://blah:blah#blah.compute-1.amazonaws.com/blah
SHARED_DATABASE_URL => postgres://blah:blah#blah.compute-1.amazonaws.com/blah
airlift:projects $
Then you should be able migrate your db.
Hey #redronin thanks for helping me find a way to connect to my postgres database on Heroku, however as a newbie to Heroku and postgresql I had to reverse engineer what "blah" was. So I figure I would break it down to help others as you helped me.
postgres://[user]:[password]#[servername].compute-1.amazonaws.com/[database]

Tutorial demo_app won't work on heroku

I'm trying to run the chapter two demo_app from the Ruby on Rails 3 Tutorial book on Heroku and it is not working. gws-demp-app.heroku.com gives the default Rails page, but gws-demo-app.heroku.com/users gives a web page that says "We're sorry, but something went wrong." On my desktop it works fine. I'm using the tools from RailsInstaller.org.
I had problems with heroku rake db:migrate at the end of the chapter not finding the activerecord-postgresql-adapter so I did install gem pg, bundle install, and updated the Gemfile and repositories. Everything is on github at https://github.com/gwshaw/demo_app.
What looks like the same problem appears at https://stackoverflow.com/questions/7619551/heroku-rake-dbmigrate-success-but-not-showing-in-app
I tried heroku restart recommended there, but that causes: Restarting processes... C:/RailsInstaller/Ruby1.9.2/lib/ruby/1.9.1/net/http.rb:6
44:in `initialize': getaddrinfo: No such host is known. (SocketError)
I tried what is claimed to work, precompiling assets with bundle exec rake assets:precompile, but that generates an error: C:/RailsInstaller/Ruby1.9.2/bin/ruby.exe C:/RailsInstaller/Ruby1.9.2/bin/rake as
sets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
TypeError: Object doesn't support this property or method
(in C:/Sites/rails_projects/demo_app/app/assets/javascripts/application.js)
I'm new to ruby and rails so I'm at a loss. Any ideas?
Solved below.
Yes , this worked for me too after installing the pg gem, I ran the following:
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
after invoking these commands, I was able to successfully open the demo_app on heroku.
Thanks for your post — I'm new to Rails, but reading your post helped me with a very similar issue.
Here's what worked for me:
Install pg gem to use postgreSQL on Heroku: (related article)
sudo gem install pg
Install taps gem to allow push of your local database to Heroku: (related article)
gem install taps
then the following sequence…
bundle exec rake assets:precompile
git add .
git commit -am "add a note reflecting changes made"
git push
heroku create
git push heroku master
heroku rake db:migrate
heroku db:push
If you're still having trouble, these articles are helpful too:
Stack Overflow - Heroku command: Heroku Rake db:migrate fails
Heroku - Getting Started with Rails 3.0 on Heroku/Cedar
The problem with bundle exec rake assets:precompile was the key and is solved here RoR Precompiling Assets fail while rake assets:precompile - on basically empty application.js
Oddly, Heroku wouldn't automatically precompile the assets on a git push heroku and thus would not find them. I don't think this little demo_app even uses assets, so that may be why it didn't precompile, but it still could not find applicaiton.css and failed. Once I set config.log_level = :debug in production.rb, I could see the problem in the logs. With the precompile working due to the above fix, everything worked.

Resources