class RegisterUserController < ApplicationController
def register @title = “Register”
if request.post? @user = User.new(params[:user])
if @user.save
flash[:notice] = “User with login #{@user.screen_name} created
successfully!”
redirect_to :action => :index
end
end
end
def index @title = “Temporary View” @users = User.find(:all)
end
def login
end
def logout
end
end
DATABASE
class CreateRegisterUsers < ActiveRecord::Migration
def self.up
create_table :register_users do |t|
class CreateRegisterUsers < ActiveRecord::Migration
def self.up
create_table :register_users do |t|
This is creating a table register_users, so the class containing a
screen_name column is RegisterUser not User, unless you have
overridden this in class User.
So i have to change user ro RegisterUser everywhere in the controller
views etc?
That depends on what you are doing. You should have a model and table
that agree with each other (User and users or RegisterUser and
register_users). RegisterUsers sounds a strange name for a model and
table though. Usually a table maps to something in the real world
(such as users). If you have a table called register_users then does
each row represent a RegisterUser (whatever that is)? There need not
be a controller with the same name however, so I am guessing that
maybe the controller should be called register_users as that is what
it does. Only you know what your app is supposed to be doing though.
class CreateRegisterUsers < ActiveRecord::Migration
def self.up
create_table :register_users do |t|
This is creating a table register_users, so the class containing a
screen_name column is RegisterUser not User, unless you have
overridden this in class User.
Colin
Hi thanks for the response, ah,your right because i had to create the
model, view, controller as register_user instead of user(which was how
it was done from a tutorial!, I copied the code form that same tutorial)
it just that i get aload error message when i change it to RegisterUser
and a name error message when i then tried register_user as well
So i have to change user ro RegisterUser everywhere in the controller
views etc?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.