[Rails] Re: additional model attributes

2011-10-25 Thread Lukas M.
hi, that works but not in the case when i would like to do something like this: user_place = Location.new(:place = place, :user = user) user_place.to_json //address is missing -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google

[Rails] Re: additional model attributes

2011-10-25 Thread Tim Shaffer
I think for Rails to recognize that the attribute should be included, you need to use attr_accessible rather than the Ruby method attr_accessor. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To view this discussion on the web visit

[Rails] Re: additional model attributes

2011-10-25 Thread Lukas M.
hm.. no luck with that either. when i try to print out the places object in the console (logger.debug @place.to_yaml), address is missing. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To

Re: [Rails] Re: additional model attributes

2011-10-25 Thread Peter Vandenabeele
On Tue, Oct 25, 2011 at 5:00 PM, Lukas M. li...@ruby-forum.com wrote: hm.. no luck with that either. when i try to print out the places object in the console (logger.debug @place.to_yaml), address is missing. From the top of my head (not hard tested now). Now you refer to to_yaml, in

Re: [Rails] Re: additional model attributes

2011-10-25 Thread Frederick Cheung
On 25 Oct 2011, at 16:00, Lukas M. li...@ruby-forum.com wrote: hm.. no luck with that either. when i try to print out the places object in the console (logger.debug @place.to_yaml), address is missing. For json at least you could override the as_json method to add the attributes you want.

[Rails] Re: additional model attributes

2011-10-25 Thread Jeff Lewis
One alternative in terms of dynamically adding an attribute to a model instance (without having to have pre-defined any attr_... in the class): ... place = Place.new place.name = place.name place.id = place.id place['address'] = external_api_place_data.address ... From then on, for