Forum: Ruby on Rails q: master/child where children are added with ajax

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-26 21:32
(Received via mailing list)
Say my user creates an Article and an Article has_many :links. The edit
form
for article contains an "add link" link_to_remote that brings up an edit
line for links for further reading. The problem is that there is that
the
Article is not yet saved, so it's unclear how to accumulate or remove
these
items.

I'm sure others have implemented similar things. Hints?

Thanks
--
View this message in context:
http://www.nabble.com/q%3A-master-child-where-chil...
Sent from the RubyOnRails Users forum at Nabble.com.
D9e2373e02d17a49738e5af1de5d2434?d=identicon&s=25 Paul (Guest)
on 2006-04-26 23:28
Steve Ross wrote:
> Say my user creates an Article and an Article has_many :links. The edit
> form
> for article contains an "add link" link_to_remote that brings up an edit
> line for links for further reading. The problem is that there is that
> the
> Article is not yet saved, so it's unclear how to accumulate or remove
> these
> items.
>
> I'm sure others have implemented similar things. Hints?
>
> Thanks
> --
> View this message in context:
> 
http://www.nabble.com/q%3A-master-child-where-chil...
> Sent from the RubyOnRails Users forum at Nabble.com.

Save the parent before using it then you have the ID. If the users
cancels, destroy it
Ef0db53920b243d6758c2f6b1306df0d?d=identicon&s=25 Steve Ross (cwd)
on 2006-04-26 23:46
(Received via mailing list)
So you're advocating:

link_to_remote 'new child', :url => {:action => 'do_something'}

def do_something
  save_master_record
  fall_through_to_rjs_add_child_records
end

BTW: Sorry about the numerous posts of the same question. Nabble hung
and I
didn't know whether the post got through. Maybe email *is* better :)
--
View this message in context:
http://www.nabble.com/q%3A-master-child-where-chil...
Sent from the RubyOnRails Users forum at Nabble.com.
This topic is locked and can not be replied to.