string - is for small data types such as a title. (Should you choose string or text?)
:text - is for longer pieces of textual data, such as a paragraph of information
:binary - is for storing data such as images, audio, or movies.
:boolean - is for storing true or false values.
:date - store only the date
:datetime - store the date and time into a column.
:time - is for time only
:timestamp - for storing date and time into a column.(Whats the difference between datetime and timestamp?)
:decimal - is for decimals (example of how to use decimals).
:float - is for decimals. (Whats the difference between decimal and float?)
:integer - is for whole numbers.
:primary_key - unique key that can uniquely identify each row in a table
rails g model User name:string email:string task_id:integer
curl -XGET localhost:3000/users
[{"id":1,"name":"bob","email":null,"created_at":"2015-04-19T22:00:03.075Z","updated_at":"2015-04-19T22:00:03.075Z"}]
curl -XPOST localhost:3000/users/1/tasks -d '{"name":"rails generate"}' --header 'Content-Type: application/json'
# should create a new task
# replace `:id` with an id of a task that you have
curl -XPUT localhost:3000/users/1/tasks/:id --header 'Content-Type: application/json'
# should return a task with `completed` set
# replace `:id` with an id of a task that you have
curl -XDELETE localhost:3000/users/1/tasks/:id
# replace `:id` with an id of a task that you just deleted
curl -XGET localhost:3000/users/1/tasks/:id -v
# should return an error
#open
Rails c
#close
exit
Creating new user on the console
u = User.new
u.save
User.all
---
Creating new exercise on the console
e = Exercise.new
e.save
Exercise.all
---
Update
u = User.find(1)
u.exercise_id = 1
u.save
---
Find the first exercise of the user Steve
User.where(name: 'Steven').first.exercises
----
Find the all exercise of the user Steve
User.where(name: 'Steven').exercises