6.3 make model, view, controller work together.
1. let's start to console without --sandbox param to create some record into our database:
?
?
def show@user = User.find(params[:id])end
?
we need to explain sth here,?
?
params is a hash for controller to use:
params[:controller]?
params[:action]
params[:id]
?
debug(params)
is a very useful method, ti will provide useful feedback, and it is very good habit to use it when you have some unexpected things happened.
?
3. we still need route to make things work. we will follow REST architecture.
?
resources :users
?
then you will get this route: ? users/1
?
?
4. it is a good timing to git commit your changes:
?
git add .
git commit -m "finished first half of the user model"
?