rails generate scaffold shibin congming: title

课程里面讲>generate scaffold 是告诉rails去建立一堆档案让topics可以动,

考虑重点是动?那么rails generate model vore topic_id:integer呢?


topics 和shibin 什么关系,可不可以用shibins

????????


rails 路由设定:

config/routes.rb,,,在里面加一行:root“???”

在atom用错中英文符号,例如“”和""会出问题,topics缺少s会出文体。



把建立起来的scaffold和model联系起来的方法:has _many,,and.  belongs_to,,,,,然而要注意里面:一对一关系,就像产品只需要一个发票,要这样表示: dependent: :destroy


让大家可以投票的方式

@topic = Topic.find(params(:id))

从资料库里面用id找到topic 然后存进@topic变数里面

@topic。voters.create

给目前的这篇topic新增一笔投票记录,然后存进资料库里面,

redirect_to(topics_path)

跟浏览器说要回到topics_path

你可能感兴趣的:(rails generate scaffold shibin congming: title)