Search code examples
androidiosturbolinksturbolinks-iosturbolinks-android

Turbolinks - How to open native camera/gallery on form button click


I am developing an Android and iOS webapp using Turbolinks.

I'm trying to implement taking a new picture or selecting one from the gallery using the native views/process.

I have this line in my form

<input type="file" accept="image/*" capture="camera" id="capture"> 

It works as expected when I visit my webapp through the browser. However, clicking the input while running the Turbolinks app does nothing. I suspect it is because the input field is not a link, so does not trigger visitProposedToLocationWithAction().

How can I manually trigger the native photo taking/selecting flow when this input is clicked?


Solution

  • I ended up using carrierwave. If you follow the instructions and add it to your model it works just fine.

    More specifically, that input line would change to

    <%= f.file_field :image, id: "image-select", class: 'form-control' %>