Hi,
I’m pretty new to Rails. I’ll explain what I did.
I created a model called User. I edited the migration file to look
like this (no table name pluralization) :
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :user do |t|
t.column :email, :string
t.column :password, :string
t.column :user_type_id, :string
t.column :client_id, :integer
t.column :firstname, :string
t.column :lastname, :string
t.column :write_permission, :boolean
t.column :notify, :boolean
t.column :type, :string
end
end
def self.down
drop_table :user
end
end
Since I will also have a ContactPerson which will inherit from User,
there is a “type” field.
Okay, then I migrated the database, and then used scaffolding to
generate a controller.
Now I’m trying to add some basic validation to the model, so I did
this :
class User < ActiveRecord::Base
validates_presence_of :email
end
Nothing fancy yet. But now, when I try to add a new user (using the
scaffold-generated views), I’m getting this error :
ArgumentError in UserController#create
wrong number of arguments (1 for 0)
The automatically generated create looks like this :
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = ‘User was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end
I’m a bit stuck because of this. Any help would be greatly
appreciated. Thanks!