我是 Rails 新手,我正在努力学习这项技术,所以如果问题很愚蠢,请原谅。
我正在使用 Rails 3 。
请让我知道如何在数据库中插入记录。
我正在使用 postgresql,下面是学生表的表结构。
SELECT column_name FROM information_schema.columns WHERE table_name ='Students';
column_name
-------------
id
name
age
description
(4 rows)
这是我的控制器文件 student_controller.rb
class StudentController < ApplicationController
def new
end
end
这是我的模型文件 student.rb
class Student < ActiveRecord::Base
end
这是我在 \app\views\student\new.html.erb 下的视图文件
<h1>BookController#new</h1>
<form>
Id: <input type="text" name="id" /><br />
Last Name: <input type="text" name="lastname" />
Age: <input type="text" name="age" />
Desciption: <input type="text" name="description" />
</form>
当我访问http://localhost:3000/student/new
请让我知道如何在数据库中插入记录?