On Jun 11, 9:53 am, Valentino Lun <[email protected]>
wrote:
> I use the following ruby code to insert a new record, but I think it is
> not clever.
>
> a = Event.new
> a.cluster_code = "KWC"
> a.hosp_code = "CMC"
> a.save
> b = EventDetail.new
> b.id = a.id.to_i
> b.detail = "This is detail"
with associations you get a.build_event_detail for free. The
associations guide ( http://guides.rubyonrails.org/association_basics.html
) has more details
Fred
>
> Any one have a better solution? Please share.
>
> Many thanks
> Valentino
> --
> Posted viahttp://www.ruby-forum.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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---