App Link - rails-heroku-app-by-kush.herokuapp.com
- Install ruby-1.9.3-p392 using rvm
$ rvm install 1.9.3-p392
$ rvm use 1.9.3-p392 --default
- Install postgreSQL 9.2.4
$ brew install postgresql (on Mac)
-
Install bundler
$ gem install bundler
-
Create an account on heroku Signup on Heroku
-
Install Heroku toolbelt Heroku Toolbelt
-
Login to Heroku
$ heroku login
Enter your heroku email and password
-
Create a new rails app
$ rails new myapp --database=postgresql $ cd myapp
-
Install bundler
$ gem install bundler
-
Start the postgres server
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
-
Execute the SQL script from the following location: db.sql
$ psql -f db.sql
-
Open config/database.yml and modify
password
with
password: password1
everywhere in the file. Then add the line
host: localhost
at the end of each group
-
Create database
$ rake db:migrate $ rake db:setup
-
Add the gem rails_12factor in gemfile by adding the following line in it
gem 'rails_12factor', group: :production
-
Specify ruby version in gemfile by adding the following line in it
ruby "1.9.3"
-
Run bundle install
$ bundle install
-
In config/application.rb set the following configuration
config.assets.initialize_on_precompile = false
-
Store your app in git
$ git init $ git add . $ git commit -m "init"
-
Create heroku app
$ heroku create
-
Add your ssh keys to heroku
$ heroku keys:add ~/.ssh/id_rsa.pub
-
Deploy your code to heroku
$ git push heroku master
-
Ensure we have one dyno running the web process type
$ heroku ps:scale web=1
-
To see your app on heroku
$ heroku open
-
To see your app locally
$ bundle exec rails s
-
Open Github and login with your username and password
-
Create a new repository with the name herokuapp
-
To add your app to github
$ git remote add github git@github.com:mrkushjain/herokuapp.git $ git push github master
-
Get Heroku Info
$ heroku info
-
Get Remote info
$ git remote -v
-
Go to heroku app dashboard on browser and click on settings next to the app
-
Enter a new name and click on save
-
On the terminal type
$ git remote rm heroku $ heroku git:remote -a newname
where newname is the app's new name
-
Your new app is now accessible at new-name-of-app.herokuapp.com
-
Add rspec rails in your gemfile
group :development, :test do gem 'rspec-rails' end
-
Run bundle install
$ bundle install
-
Go to your terminal and use the same ruby version as you had you used while compiling postgres
$ rvm use ruby-1.9.3-p392
-
Initialize the spec/ directory
$ rails generate rspec:install
-
Run Tests with
$ bundle exec rake spec
-
Add gem factory_girl_rails under development and test groups
group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' end
-
Run bundle install
$ bundle install
-
Add gem shoulda matchers in your gem under test
group :test do gem "shoulda-matchers" end
-
Run bundle install
$ bundle install