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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -