How does Shrine handle nested attributes?

257 views
Skip to first unread message

marcam...@gmail.com

unread,
Nov 4, 2016, 5:09:49 PM11/4/16
to Shrine
I have a `Profile` model, that `has_many :transcripts`. Each `transcript` can have many file uploads (PDFs).

When I create a new profile, I would like to be able to create a new transcript and add multiple file uploads to that transcript record at the same time (via accepts_nested_attributes_for).

Will Shine be able to handle the successful uploading of those 3 files to S3 and associate it with both that `transcript` object and the newly created `profile` object?

Is this spelled out in any of the docs anywhere, because I was looking through some of it and I couldn't find any mention of nested_attributes support.

Thanks in advance.

Janko Marohnić

unread,
Nov 5, 2016, 1:22:07 AM11/5/16
to marcam...@gmail.com, Shrine
Yes, this is possible with Shrine, you can implement it just like any other dynamic has many association (using `accepts_nested_attributes_for`). But I happen to also already be writing a guide for that, which should be finished today or tomorrow, so I will let you know.

Kind regards,
Janko

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.
To post to this group, send email to ruby-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-shrine/abe2a223-76e6-4024-9b6a-0a897bf956cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

marcam...@gmail.com

unread,
Nov 5, 2016, 3:48:25 AM11/5/16
to Shrine, marcam...@gmail.com
That's awesome to know Janko. 

As soon as I see that guide, I will begin the switch from Carrierwave. 

Thanks for the reply!

On Saturday, November 5, 2016 at 12:22:07 AM UTC-5, Janko Marohnić wrote:
Yes, this is possible with Shrine, you can implement it just like any other dynamic has many association (using `accepts_nested_attributes_for`). But I happen to also already be writing a guide for that, which should be finished today or tomorrow, so I will let you know.

Kind regards,
Janko
On Sat, 5 Nov 2016 at 05:09, <marcam...@gmail.com> wrote:
I have a `Profile` model, that `has_many :transcripts`. Each `transcript` can have many file uploads (PDFs).

When I create a new profile, I would like to be able to create a new transcript and add multiple file uploads to that transcript record at the same time (via accepts_nested_attributes_for).

Will Shine be able to handle the successful uploading of those 3 files to S3 and associate it with both that `transcript` object and the newly created `profile` object?

Is this spelled out in any of the docs anywhere, because I was looking through some of it and I couldn't find any mention of nested_attributes support.

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Shrine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine...@googlegroups.com.

Janko Marohnić

unread,
Nov 5, 2016, 4:55:17 AM11/5/16
to Marc Gayle, Shrine
Here it is: https://github.com/janko-m/shrine/blob/master/doc/multiple_files.md

Note that it doesn't come with any JavaScript examples, as that could be written in variety of ways. I would recommend taking a look at a very similar multiple files JavaScript implementation in the demo app, as well as the Dynamic Forms Railscast for an example on how to generate the nested fields on the client side.

Kind regards,
Janko

To unsubscribe from this group and stop receiving emails from it, send an email to ruby-shrine+unsubscribe@googlegroups.com.

To post to this group, send email to ruby-...@googlegroups.com.

marcam...@gmail.com

unread,
Nov 5, 2016, 12:48:52 PM11/5/16
to Shrine, marcam...@gmail.com
Ahh ok. Interesting.

To handle nested attributes I will be using the cocoon gem. That should work just fine, right?

I am going to try out this implementation either today or tomorrow and let you know if I have any problems here, if that's ok.

Thanks again for both this wonderful gem and being so responsive. I really appreciate it!
Reply all
Reply to author
Forward
0 new messages