Skip to content

Instantly share code, notes, and snippets.

@charliegerard
Last active August 29, 2015 13:57
Show Gist options
  • Save charliegerard/9631777 to your computer and use it in GitHub Desktop.
Save charliegerard/9631777 to your computer and use it in GitHub Desktop.

#Day18

Morning warmup: (https://gist.github.com/wofockham/241c21478b5d593b7830)

Ruby api: (http://api.rubyonrails.org/)

http://api.rubyonrails.org/classes/ActionView/Helpers.html

###Setting up rails project

  • cd in the folder you want

  • rails new "name of folder" -d postgresql

  • cd in this folder

  • modify gem file to add gems

  • Run bundle install

  • Change database.yml file

  • rake db:create

  • rails generate migration create_"name of table"

  • make changes in migration rb file (add your table details)

  • Then run rake db:migrate

  • Then rails generate migration create_"name of table" again to create 2nd table etc...

  • rake db:migrate

  • you can check the schema file to check if you have the right tables

  • Create your rb files for your classes in the models folder

  • Run annotate to add your tables to your database

  • Then open seeds.rb and hardcode data

  • Run rake db:seed in the terminal to add the value added in seed.rb

  • rake routes gives us all our routes

  • In routes file, add "resources :artists, :works" and then run "rails generate controller Artists index create new edit show update destroy" -> Creates our views files with all the methods in it.

  • Delete the prepopulated "gets" in routes.

  • Run rake routes to check

Formatting date in rails: (http://apidock.com/ruby/DateTime/strftime)

http://guides.rubyonrails.org/form_helpers.html#making-select-boxes-with-ease

###Homework:

Read more about form helper and migrations Style moma

https://gist.github.com/wofockham/1b0bf009800b0bcd4ec9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment