I am still new to Rails and am having trouble understanding how to render certain sections of a page conditionally. I have a button in index.html.erb
as well as another partial rendered:
<%= @facade.processing_button %>
<%= render 'snap', app: @facade.app %>
Which is defined as follows:
link_to processing_path(@app.id),
method: :post, action: :processing,
class: 'btn btn-danger' do
concat([
image_tag('blah', class: 'check_icon'),
content_tag(:span, 'Processing')
].join(' ').html_safe)
end
This button calls a controller method:
def processing
if service.upload
# render success bar?
else
# render error bar?
end
end
I would like to render something like the following pictures. In the snap partial, a section looks like this normally:
Once the button is clicked, if the action is successful I want to render the following green success bar:
It is unclear to me how to accomplish this. Should I be leveraging some form of JS/CoffeeScript? Should I add the bars to the partial as hidden by default and simply show them with JS when the action is completed?