Hi guys! I believe I found a simpler solution for this issue on ActiveStorage.
Just put this hidden_field on your form:
<%= f.hidden_field :image, id: nil, value: params[:post][:image] rescue nil %>
And there is no need to do any treatment on your controller.
Your form will end up like this:
<%= form_with(model: @post, local: trye) do |f| %> <%= f.text_field :title %> <%= f.text_area :body %> <%= f.hidden_field :image, id: nil, value: params[:post][:image] rescue nil %> <%= f.file_field :image, direct_upload: true %> <% end %>
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi guys! I believe I found a simpler solution for this issue on ActiveStorage.
Just put this hidden_field on your form:
And there is no need to do any treatment on your controller.
Your form will end up like this: