I'm using the simple form gem in my ruby on rails app. In my app, I'm also using ActiveStorage to hold images.
I'm using Krajee
jquery file-input
I want to be able to upload images using the simple form gem. Here is my input:
<%= f.input :image, input_html: { id: :image_input } %>
I'm supposed to initialize the input using this command (as provided by the docs)
<script>
$(function() {
// initialize with defaults
$("#image_input").fileinput();
// with plugin options
$("#image_input").fileinput({'showUpload':false, 'previewFileType':'any'});
});
</script>
The jquery code is not hiding the input. I have checked if jQuery is installed and made sure that it was working. I imagine that the problem lies somewhere in the way I'm creating my input field, but I'm not too sure.
Any help is appreciated.
UPDATE
When I check the page source, the input does have the correct id, however, the style of the input is set to display: none
. I'm guessing that has something to do with the Krajee Library.
I tried this post: Change id in simple form
it did not work.