Access denied, Please sign in and make sure you have proper permission.
class TopicController < ApplicationController
def index
@topics = Topic.all
end
end
index action 取出了 @topics,你不需要调用 render 方法,然后 Rails 就知道需要使用 app/views/topics/index.html.erb 这个模板去渲染。
rails generate migration addShitToTable
比如关于 ActiveRecord 的惯例:
在 Model 中,类名:Book,对应的数据库表名:books
比如 rails g controller Topics
会生成 TopicsController, TopicsHelper, topics 目录,再比如单复数问题!
我以前是写 java 的,为了数据库连接等问题,需要进行非常多的 xml 文件配置,很烦人