First, the usual process of:
- rails new
- (edit Gemfile)
- bundle install --without production
- bundle update
- git init
- git add -A
- git commit -m "Initialize repository"
- (edit readme file, rename, commit change)
- (the below commands create a new bitbucket repository)
- git remote add origin git@bitbucket.org:<username>/sample_app.git
- git push -u origin --all
- (add in hello by adding hello function to application_controller file and adding "root application#hello")
- git commit -am "Add hello"
- heroku create
- git push heroku master
- (create a new branch)
- git checkout master
- git checkout -b static-pages
- rails generate controller StaticPages home help
- (add newly created files to repository)
- git add -A
- git commit -m "add a static pages controller"
- git push -u origin static-pages
- bundle exec rake test (checks that tests added automatically pass)
- (add about test)
- test "should get about" do \\ get :about \\ assert_response :success \\ end
- (To ensure test passes)
- add a line in routes/config.rb: get 'static_pages/about'
- add a line in static pages controller: def about // end
- "touch app/views/static_pages/about.html.erb"
(create an about.html.erb page in app/views/static_pages/) - add html to about page
- (Systematic steps to prevent DRY: Don't repeat yourself)
- as a learning step, to see that things must be done repetitively without it, rename application.html.erb (i.e. rename page template)
- for each of the erb pages, add <% provide(:title, "preferredtext") %> at the top. and add <%= yield(:title) %> in the original title page.
- rename back application.html.erb, and edit it to include the html, title, head tags (which should be deleted from the other erb files), as well as the <%= yield(:title) %> line
- Edit config/routes.rb to have "root 'staticpages#home'" (remember to delete existing root)
- (the usual)
- git add -A
- git commit -m "finished static pages"
- git checkout master
- git merge static-pages
- git push
- bundle exec rake test
- git push heroku