首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

6.3 make model, view, controller work together

2012-10-06 
6.3 make model, view, controller work together.1. lets start to console without --sandbox param to

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"

?

热点排行