Save only inserts null instead of actual values


#1

Hi,

whenever I try to save my form, rails only enters null values in my
database. I’m using sqlite, I thought that sqlite might be the problem,
but the problem remains when I switched to mysql. Here is my code:

controller:
class CollectionController < ApplicationController
def new
@collection = Collection.new
end

def create
if request.get?
redirect_to :action => ‘new’
elsif request.post?
@collection = Collection.new(params[:collection])
if @collection.save
flash[:notice] = ‘Collection was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end
end
end

model:
class Collection < ActiveRecord::Base
has_many :subcollections

attr_accessor :name, :description, :index_date
end

database.yml:
development:
adapter: sqlite3
dbfile: db/dev.db

development.log - after submitting data with the form
Processing CollectionController#create (for 127.0.0.1 at 2006-02-08
22:13:53) [POST]
Parameters: {“commit”=>“Opslaan”, “collection”=>{“name”=>“dqsfqds”,
“description”=>“qfdsqsd”}, “action”=>“create”,
“controller”=>“collection”}
e[4;36;1mSQL (0.010000)e[0m e[0;1mPRAGMA table_info(collections)e[0m
e[4;35;1mSQL (0.000000)e[0m e[0mINSERT INTO collections (“name”,
“description”, “index_date”) VALUES(NULL, NULL, NULL)e[0m
Redirected to http://localhost:3000/collection/list
Completed in 0.17000 (5 reqs/sec) | DB: 0.01000 (5%) | 302 Found
[http://localhost/collection/create]

I really don’t see it, I really don’t. It is probably something very
stupid! All help is greatly appreciated.

Kind regards,

Nick