My Sinatra apps no longer seem to do anything when running rake db:migrate or rake db:migrate:status. No error messages or any other output, and the schema is not generated. rake db:create_migration works as expected. Old apps that previously worked no longer do. Rails apps still work fine.
I have had a number of Ruby/RVM/rbenv issues but I think (hope?) they are settled, and am using Ruby 2.6.0, Sinatra 2.0.7, Active Record 6.0.0 & Sinatra-activerecord 2.0.14
Apparently there are issues with ActiveRecord 6.0. Changing my Gemfile to
activerecord, "5.2.3" fixed everything.
Related
I noticed that the new version of Michael Hartl's Ruby on Rails Tutorial says to include the following to serving static assets on Heroku
gem 'rails_12factor', group: :production
The previous version of his book did not have that. Can someone explain the details of what happened with Heroku that requires this gem?
The best answer I could find is by looking at the rails_12factor README.
There's also a discussion on why Heroku decided to include the gem: Why does this gem exist?
Especially read the answer from schneems about halfway down the page.
This gem enables serving assets in production and setting your logger to standard out, both of which are required to run a Rails 4 application on a twelve-factor provider. The gem also makes the appropriate changes for Rails 3 apps.
In the Getting Started with Rails 4.x on Heroku, we can read this:
Heroku integration has previously relied on using the Rails plugin system, which has been removed from Rails 4. To enable features such as static asset serving and logging on Heroku please add rails_12factor gem to your Gemfile.
Older question, but FWIW Rails 5 Apps do not require the rails_12factor gem. Per the README:
We worked with the Rails core team to make Rails 5 work on twelve-factor platforms out of the box.
There is also a snippet for migrating to Rails 5.
Just ran into a problem with a Rails 4 application on Heroku and couldn't debug it with heroku run logs. Without the rails12factor gem, you can't see the full logs that you normally see on your console in development. I was getting a 500 error and there wasn't any available information.
It actually didn't tell me that migrations were pending without rails12factor
As of Rails 5, you no longer need to include this gem in your Gemfile. They've removed it from their documentation also: https://github.com/railsbridge/docs/issues/569
I have a Rails app running on heroku. Now I want to run a rake task (which uses a model of my rails app) and geo-tag each record using the MaxMind GeoIP database (http://www.maxmind.com/app/geolite).
Using this database in a Ruby application involves :
Building it's C-API (http://www.maxmind.com/app/c) and then
Build the Ruby bindings for that (http://www.maxmind.com/app/ruby).
I could do this on my local machine and successfully get the country codes from IP addresses. However I do not know how to install these libraries on Heroku. From what I understand the ruby bindings are not available as a gem with native extensions (which heroku would have handled just fine). Also their C-API seems to have a few other dependencies which makes me wonder whether such a thing is possible at all.
So has anyone installed the MaxMind GeoIP (a.k.a Net::GeoIP) on Heroku? If yes how?
I could run the rake task from my laptop by pointing my local setup to the production DB. Before that I would like to know if I can run it from my Heroku setup itself to avoid latency or connection breakdown etc.
I found a gem which bundles the MaxMind C-API and provides it's own Ruby API. It works just fine - http://rubygems.org/gems/geoip
I ll tentatively accept this as the answer. However it would be awesome if someone can tell me how to install binary extensions to Ruby on Heroku.
I've had some problems running an app on Heroku. It uses Sinatra and Datamapper. The full project is here: https://github.com/pixelwolf/phonedb
The problem happens when I deploy the app, all goes well, until I go to the url, where I get an "Application Error" page. I have also push the SQLite3 database using heroku db:push sqlite://database.db
Here are the logs from running heroku logs: https://gist.github.com/1439777
You have to configure your database in datamapper with a line like this
DataMapper.setup(:default, ENV['DATABASE_URL'] || 'sqlite3://my.db')
That was from heroku's website. http://devcenter.heroku.com/articles/database That will configure datamapper to continue to allow you to use sqlite3 on your local machine but switches to Heroku's postgres DB when the application is used there.
Also, Tom Anderson is correct, you need to add the dm-postgres-adapter gem to your Gemfile. I also added the pg gem as well, I'm not sure if that was necessary though.
The error page has the line:
`require': no such file to load -- dm-postgres-adapter
You can only use postgres on heroku. So likely you are not accounting for that in some way. You can develop with sqlite on your machine, but you then need to arrange a few things to make it all work, plus you need to not use any sqlite or postgres only features.
Adapters not working with datamapper
Heroku and Datamapper problems
http://www.ruby-forum.com/topic/1770484
I can launch a basic app on Heroku, displaying a message with get '/'... works just fine. However, whenever I try to add sqlite with datamapper, the thing breaks down.
In order to see my app structure, check out the project on github. I've kept the code pretty bare-bones.
In the log from heroku I'm getting:
2011-06-26T21:28:36+00:00 app[web.1]: /app/.bundle/gems/ruby/1.9.1/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:163:in `require': no such file to load -- dm-postgres-adapter (LoadError)
The thing about this is that I'm not using postgres, so I'm confused why it is saying this.
"The thing about this is that I'm not using postgres, so I'm confused why it is saying this."
You're using Heroku, so you are using Postgresql.
In your app.rb you have this line:
DataMapper::setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/notes.db")
which I'm guessing you got from the Heroku database docs. This line basically says "check for the environment variable 'DATABASE_URL', and if it's set use it as the database url, otherwise use the Sqlite url". Running locally this environment variable won't be set, so you'll use the Sqlite url, but on Heroku this will be set to something like (see the page linked above):
postgres://username:password#hostname/database
Datamapper will see that this is a Postgresql url, and try to require the postgres adapter, which isn't installed so will result in the error that you see.
The best solution would be to install Postgresql locally, so that your development and production environments are as similar as possible. If you can't do this, or don't want to, you can specify the Sqlite adapter locally, and the Postgres adapter in production. It'll look something like this in your Gemfile:
group :development do
gem 'dm-sqlite-adapter'
end
group :production do
gem 'dm-postgres-adapter'
end
If you do this you'll need to tell Heroku to which groups to leave out when installing gems, see the Heroku Gem Bunder docs.
You are moving from sqlite to postgres-sql and thus you should include dm-postgres-adapter in your Gemfile (and install it ofcourse).
Heroku only supports a read-only file system (or at least only supports read-only operations for any files that you want to be persistent). Hence, you can't use SQLite on Heroku. Heroku only supports PostgreSQL as a database so you need to configure DataMapper to use PostgreSQL (see Yet Another Geek's answer).
I'd recommend installing PostgreSQL in your development environment if you're planning to deploy to Heroku. Every database is a little different and no ORM will protect you from the differences. A bit of searching for questions tagged heroku and postgresql should show some of the problems you'll have if you develop on top of one database but deploy on another.
I am trying to get Passenger working on my local OSX machine as I need to have non-port based urls for testing a post-back from a payment gateway, and I do not want to develop on the server!
I get the error: "You have already activated rack 1.0.1, but your Gemfile requires rack 1.2.1." when trying to load the site via Passenger (using the Passenger PrefPane in OSX).
It was wokring fine previously with "rails server" (WEbrick).
I got an error from Passenger about mysql - I am using mysql2 - so I tried removing 'mysql' which was in my Gemfile and leaving mysql2. This seemed to solve that issue, but since then I have been stuck on this Rack issue.
(on a side note also having trouble installing mysql via bundle..)
I saw that newer versions of Passenger don't have this problem. Installed the lastest but no joy (does it matter if I use the PrefPane?)
I feel like I might be about to get my system into a mess so looking for some advice on this!
Thanks
It's because Phusion Passenger tries to load (the latest version of) Rack after which your app tries to load a specific, different version of Rack. Make sure you activate your bundle from config/setup_load_paths.rb, which is called before Phusion Passenger loads Rack.