How to create a Rails app with PostgreSQL

9 de agosto, 2016 @ 13:56 — 0 comentariosDownload PDF

First we must go to Hosting Panel and create a new ruby app in the zone of ruby applications.
In the following guide you will find more detailed instructions on this point:

Guide: Create a rails 5 app from zero

Once the Ruby app is ready, we need to access through SSH to our hosting and launch these commands:

gem install rails
cd ruby ; rails new ruby_app_name -d=postgresql

Having done this, we must go to hosting panel and create a PostgreSQL database and a user for this database. Once we have them , we configure the config/database.yml file.

We find this at the end of the file:

	<<: *default
	database: app_production
	username: app
	password: <%= ENV['APP_DATABASE_PASSWORD'] %>

we will modify it, as shown:

	<<: *default
	adapter: postgresql
	statement_limit: 200
	port: 5432
	database: user_database
	username: user_username
	password: password

Now we modify our Gemfile to meet our requirements, and install our gems:

bundle install

Finally we launch the last command:

rake db:migrate