Rails redirect after submit

Archived from the Transloadit support forum. Originally posted on September 1, 2012; details may be outdated, see our docs for current behavior. Original thread

I have a basic form with a single file upload. When the user submits the form, I want the upload to happen and redirect normally. Here is the code I have: https://gist.github.com/3584962

Right now the upload happens and the processing happens when the form is submitted even though I have wait set to false. After the form upload/process is done, I want the form to behave normally and continue with the posts#create action but redirect never happens and it tries to look for a ‘create’ view (create.html.erb)

Here is the process I would like to implement:
Form is submitted with file attached Upload happens The redirect happens normally in the posts#create action Transloadit does the processing and notifies the server when done.

I tried setting the notify_url as a parameter to transloadit_jquerify but that does not help.

-Mike

I have it fixed. It was my mistake with looking for the wrong params before redirecting.

Another question now :slight_smile: How to implement upload progress for each image like https://www.picplum.com homepage image upload. They also use you guys.

Would be awesome to show upload for each image and not a modal for the entire page.

Thanks!

Another question: I only want to submit the form to transloadit if an image is selected. I searched for validations and came across this thread https://community.transloadit.com/t/external_id/tender-questions-151

Did not really help much. Any parameter I am missing to only submit/process with transloadit if a file is selected.

Another question now :slight_smile: How to implement upload progress for each image like https://www.picplum.com homepage image upload. They also use you guys.

It looks like they added a good amount of custom code using our jQuery API to create individual uploads / assemblies for each file input, including custom display code. We’re working on adding more features like this into our jQuery plugin in the future, but for now this requires customization code on your end.

Did not really help much. Any parameter I am missing to only submit/process with transloadit if a file is selected.

Well, you simply attach your own form submit handler (before attaching the jQuery plugin). In this submit handler you cancel the event (e.preventDefault(), etc.) in case it doesn’t pass your requirements (like file input fields being filled).

HTH

Definitely helps. Thanks for the reply Felix. Got it fixed.

Will look into the custom code for the individual files.

Last question, promise: How to implement ‘http/import’ with the rails sdk?

-Mike

Last question, promise: How to implement ‘http/import’ with the rails sdk?

You just add an import step at the beginning of your assembly, and for every step that is supposed to use the imported file(s), you set "use": "step_name".

Awesome got it working. We are using the “fields” paramater on the jquery plugin to send a url along with the transloadit parameters and then access that via “${fields.url}” in the template. Is that the right way to get http/import working ?

Also I guess the rails sdk will not without a “regular” file upload field i.e. if we only want to implement a upload from url.

Just bumping this; pushing the code to production this week.

Any help?

Hey Mike,

I have contacted one of the SDK devs to help you out, but they haven’t replied here yet. I just pinged them again. Sorry for the delay.

Kind regards,
Tim

Hi Mike,

I’m one of the maintainers of the rails-sdk, hope I can help.

We are using the “fields” paramater on the jquery plugin to send a url along with the transloadit parameters and then access that via “${fields.url}” in the template. Is that the right way to get http/import working ?

Yep this looks correct and works if you want to set the URL dynamically via a form or similar.

Also I guess the rails sdk will not without a “regular” file upload field i.e. if we only want to implement a upload from url.

The rails-sdk doesn’t care much about your form, it’s just a thin wrapper around the jquery-sdk with some convenience methods. But to be sure I just tested it without a file upload field and it works as expected.

Let me know if you have other questions.

Closing this ticket for now. Please feel free to re-open it, guys, by replying to it.