rubyonrailsin

A Ruby and Rails talk

Monday, March 29, 2010


[Rails] Re: My model object's attributes are not being saved

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

On Mar 29, 10:53 am, BarryOg <barryodrisc...@gmail.com> wrote:
> Hello all,
> I'm into my first week of rails coding and I'm really enjoying it so far.

Welcome!

> I've run into a bit of an problem.  I have a user model which represents the
> currently logged in user.  I'm also creating a gas_reading model which will
> be a child of the user model.  When I attempt to create and save a new
> gas_reading its saving successfully without any exceptions but its not
> storing the attributes.  

That's because you're not letting ActiveRecord see those attributes.
Take out this line:

attr_accessor :value, :start_date, :end_date

You should already have these columns in your table from your
migration. attr_accessor is when you want your object to temporarily
keep track of data that is *not* stored in your table.

Hope this helps,

Jeff

purpleworkshops.com

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive