私はRailsを初めて使用します。このテクノロジーを学ぼうとしています。質問がばかげている場合は、失礼します。
Rails3を使用しています。
データベースにレコードを挿入する方法を教えてください。
私はpostgresqlを使用しています。以下は、Studentsテーブルのテーブル構造です。
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
データベースにレコードを挿入するにはどうすればよいですか?