Changing data in RoR
I needed to change some data that was not being submitted by my form. Your asking, what? Well say you have a form for account signups. The form has fields for: full name, email, and password. Now your database has columns for: full name, email, password, signupdate, and status. I needed to send the database some data for the account to be valid.
I could use hidden fields to submit the data but I need something more practical. Ruby on Rails makes this easy, just add what you’re missing to your controller and send your form on its way! Below is an example of what we just talked about.
[ruby]
def create
@account = Account.new(params[:signup])
@account.signupdate = Date.today
@account.stat = 1
if @account.save
flash[:notice] = ‘Your Account was successfully created.’
redirect_to :action => ‘index’
else
render :action => ‘index’
end
end
[/ruby]


