Jump to content

The ultimate community for Ruby on Rails developers.


clear data on update for accepts_nested_attributes_for fields

rails nested_attributes crud

  • Please log in to reply
4 replies to this topic

#1 Elmor



  • Members
  • 3 posts

Posted 14 August 2013 - 07:14 PM


I've created a standard CRUD in one of my controllers. Model User related to that controller has 

accepts_nested_attributes_for :address, class: 'Address' for  association (has_one). I was wondering how could i set things up on edit action so user could delete content of the nested fields and on the update action the sub model (for nested attributes) would be deleted ? Excuse me, if i didn't explain this clear enough.

#2 james



  • Members
  • 223 posts
  • LocationLeeds, U.K.

Posted 14 August 2013 - 10:13 PM

Hi Elmor.


I think this rails cast might be what you are looking for http://railscasts.co...el-form-revised


It's a paid for cast and I wouldn't normally recommend that as it's not very usefull for others but you may well find the subscription (you can cancel any time) well worth it.


The original free rails cast is a two part cast.

Part one can be found here http://railscasts.co...del-form-part-1 and there are links to part 2 plus other usefull links on that page.


I really should post some code up and help you further but it's a massive subject and I really don't have time right now. I'll try to come back later with something more constructive and of course others may well have an equally good answer for you.

Programming is just about problem solving!

#3 Jemagee



  • Members
  • 62 posts

Posted 14 August 2013 - 10:18 PM

The guy who runs rails cast is on break and if you pay the $9 right now you get a multi month subscription (I think until october, I'm not sure) it's a great way to test it out - I haven't used it much cause I'm still in the beginning stages but from what i've seen - it's worth the $9 a month - one of the best tutorial options out there

  • james likes this

#4 Elmor



  • Members
  • 3 posts

Posted 15 August 2013 - 04:19 AM

Thanks to all! I've missed this railscast, thanks again for help!

#5 lightbecorp



  • Members
  • 10 posts

Posted 15 August 2013 - 07:16 PM

Sidebar: I highly recommend paying the $9/month for RailsCasts if you do a lot of Rails development, especially with using newer versions of Rails.  The free version should be enough for the older Rails versions.  It has saved me lots of time with a good number of processes I wanted to include in my Rails applications.

Also tagged with one or more of these keywords: rails, nested_attributes, crud

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users