@ gem cocoon - how do i

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

@ gem cocoon - how do i

tommaso159
HI, i am baffled on how to make the first set of nested fields visible. 
currently, it all works, but even just in order to display the 1st set of fields, i have to click "add .... "


2)
how do i assign values to the object in the controller to the first set ?


thank you

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @ gem cocoon - how do i

Ariel Juodziukynas
Let's say you have a user that has many books, if you want to hace some book prefilled just do

@user.books.build(title: something, year: someyear)

As long as you don't reload the relationship, the books will be on the user (just not persisted) and `fields_for :books` will iterate over them

You can give a try to my gem for dynamic nested fields, I'd really appreciate it :D https://rubygems.org/gems/vanilla_nested (it's similar to cocoon but weight less than 10%, and it has no dependencies like cocoon that adds a lot of gems and depends on jquery)

El lun., 10 jun. 2019 a las 16:40, tom (<[hidden email]>) escribió:
HI, i am baffled on how to make the first set of nested fields visible. 
currently, it all works, but even just in order to display the 1st set of fields, i have to click "add .... "


2)
how do i assign values to the object in the controller to the first set ?


thank you

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcAXnPUWJ8iBxONW1Yibyyb6cLc%3D0cofMBKL_83qjYN%2BDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @ gem cocoon - how do i

Ariel Juodziukynas
If you want a blank book just do @user.books.build with no attributes

El lun., 10 jun. 2019 a las 16:45, Ariel Juodziukynas (<[hidden email]>) escribió:
Let's say you have a user that has many books, if you want to hace some book prefilled just do

@user.books.build(title: something, year: someyear)

As long as you don't reload the relationship, the books will be on the user (just not persisted) and `fields_for :books` will iterate over them

You can give a try to my gem for dynamic nested fields, I'd really appreciate it :D https://rubygems.org/gems/vanilla_nested (it's similar to cocoon but weight less than 10%, and it has no dependencies like cocoon that adds a lot of gems and depends on jquery)

El lun., 10 jun. 2019 a las 16:40, tom (<[hidden email]>) escribió:
HI, i am baffled on how to make the first set of nested fields visible. 
currently, it all works, but even just in order to display the 1st set of fields, i have to click "add .... "


2)
how do i assign values to the object in the controller to the first set ?


thank you

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcDRVXqRq37-C3pR1MDcVOB5q-EZ7m_EApOHDbpYHecbXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.