We're sorry, but something went wrong. - Heroku Hosting - ruby-on-rails

I wanted to try Heroku as a hosting method. I can go to the home page, but when I press "Sign Up" I get "We're sorry, but something went wrong." message.
Is there any way of using sqlite3 instead of Postgres? If not on Heroku, then maybe on some different hosting service?
I watched the logs but cannot see the issue there.
default: &default
database: db/development.sqlite3
adapter: postgresql
pool: 5
timeout: 5000
development:
adapter: postgresql
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: postgresql
database: db/production.sqlite3
pool: 5
timeout: 5000
I just get the "We're sorry, but something went wrong." error message
Please go to https://crassar.herokuapp.com and watch it your self

Install Heroku Postgres add-on. It's free for Hobby Dev.
Get postgres (database) url from Heroku Postgres
Add url to config vars on Heroku, like this: (Settings -> Reveal Config Vars)
variable name: DATABASE_URL
value: postgres://blabla
Edit database.yml for production
production:
<<: *default
url: <%= ENV['DATABASE_URL'] %>

Related

Changing database names from SQlite3 to Postgres

I am currently trying to switch from SQlite3 to Postgres, and was wondering how I can change my database name? According to Heroku, they say this:
Note the adapter name is postgresql not postgres or pg. You will also
need to change the database: to a custom name. A final version might
look something like this:
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_production
pool: 5
timeout: 5000
I see right now that I have the following for my database name for test environment:
test:
<<: *default
database: db/test.sqlite3
For this (and dev and production environments) do I need to simply change the name of the database, or do I need to do something more than this. Because for the SQLite3 files, it has a .sqlite3 extension. Does postgres have a similar situation?
Yes, you can just change the database name for each additional environment.
The
<<: *default
means that is the part of the configuration that will be used in the other environments, so you don't have to duplicate your code (DRY).
For postgres you don't have to give extensions (as I remember).
Just give the databases clear names, and that should work.

Setting the connection pool (and other database options) using Heroku

From this page, it looks like Heroku does most of the work in building your database.yml file on deployment, meaning that all I have to have is my development and test environment configurations.
Is there a way I can also specify production values? For example, if I wanted to set pool: 25 on production, can I include that in my database.yml as follows?
development: &default
adapter: postgresql
database: my_app_development
encoding: utf8
host: localhost
min_messages: warning
pool: 2
timeout: 5000
test:
<<: *default
database: my_app_test
-- Can I add this, or will it get overwritten?
production:
<<: *default
pool: 25
Actually, found the answer to exactly my question on the Heroku documentation
https://devcenter.heroku.com/changelog-items/426
Looks like whatever options you set will be merged in and preserved, so I can indeed set connection pool in my database.yml

Can't see my SQLite3 tables in terminal

I opened the SQLite3 console in my terminal and type .tables, but it returns nothing.
This is a problem because I have my website running in the background and I can login, logout, load news, etc.
I don't know where the tables and everything are stored.
This are some of my configuration:
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
Previously I was working on Cloud9.io and I could display everything in the terminal.
As I understand it, you launched the sqlite3 command-line utility directly. The thing is, you didn't open a database file with it, which is why it shows no tables.
Instead you should run rails dbconsole or just rails db. That will work even for other database systems, like PostgreSQL (using psql) and MySQL.
However, you could as well use rails console and just fetch your data as you would in Rails.

rake aborted! can't convert nil into Hash

rake aborted! Cannot load Rails.application.database_configuration: can't convert nil into Hash
I am trying to deploy ruby on rails on openshift, and then i try to run rake db:migrate. Then i face this problem.
I create the app with https://github.com/kohjx/TestYourCode.git on openshift with ruby on rails + mysql 5.1
Then i configure the config/database.yml
default: &default
#adapter: sqlite3
adapter: mysql2
pool: 5
timeout: 5000
database: "<%=ENV['OPENSHIFT_APP_NAME']%>"
username: "<%=ENV['OPENSHIFT_MYSQL_DB_USERNAME']%>"
password: "<%=ENV['OPENSHIFT_MYSQL_DB_PASSWORD']%>"
host: <%=ENV['OPENSHIFT_MYSQL_DB_HOST']%>
port: <%=ENV['OPENSHIFT_MYSQL_DB_PORT']%>
development:
<<: *default
#database: db/development.sqlite3
test:
<<: *default
#database: db/test.sqlite3
database: testyourcode_test
production:
<<: *default
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
#database: db/production.sqlite3
I setup the RAILS_ENV=development, but i can't figure out how to solve. Any help would be greatly appreciated!
At first glance it looks like you're using the Openshift DB as your default and then all your Rails environments are using that default setup. Your local machine (where I'm assuming you're running the rake db:migrate) isn't able to use those connection details to the OPenshift DB.
Instead of having the Openshift DB configuration in the default section move it down to the production setting and switch the RAILS_ENV=production with rhc set-env RAILS_ENV=production. Then configure the development with settings that your localmachine can use. After thats all done, try running your db:migrate once more.

Rails Change Default Projects Database 'sqllite' to PostgreSql

I'm learning ruby. I've created some application and played with it.
i wanted to change the database to postgres. I modified gemfile with
gem 'pg'
[pg already installed in usr/bin/pg]
then update database.yml with
postgresql where sqllite is used.
pg connection bad:
FATAL: role "user" does not exist
i've created some postgres user already. what should i have to change to work with postgres?
development:
adapter: postgresql
database: db/development.postgresql
pool: 5
timeout: 5000
user:
adapter: postgresql
database: db/test.postgresql
pool: 5
timeout: 5000
production:
adapter: postgresql
database: db/production.postgresql
pool: 5
timeout: 5000
If you don't specify a username to connect to PostgreSQL as, libpq will connect using the login username of the current running user.
libpq is what the Pg gem used by Rails uses to connect to PostgreSQL.
So, in your database.yml, specify the PostgreSQL user to connect to the database as with a user: entry. Make sure this corresponds to a user that exists in PostgreSQL, and that pg_hba.conf permits this user to connect.
To learn more, see the client authentication chapter of the PostgreSQL docs.
I know its a two year old question, but I just ran into the same problem, and i fixed it by changing the syntax of config.yml, then I rake db:migrate
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: yourappnamehere_development
test:
<<: *default
database: yourappnamehere_testdevelopment:
production:
<<: *default
database: YOURAPPNAME_production
username: YOURUSERNAME
password: <%= ENV['YOURAPPNAME_DATABASE_PASSWORD'] %>

Resources