ruby - Rails - getting ID of currently created element with formobject -
i know how can id of created model record, saved form object. have:
@object_form.save id = @parent.objects.last.id
i change more meaningful like:\
@object_form.save id = (currently saved object.id)
if you're saving object, , if save successful, you'll able reference id
of newly saved object:
id = @object_form.id if @object_form.save
you have remember you're not saving "form", activerecord
object. thus, if you've still got @instance_variable
available save, return newly populated id
method.
Comments
Post a Comment