I'm facing an issue with setting my own percentage in a Bootstrap progress bar. The float value is being passed to the view correctly, but for some reason, the Bootstrap progress bar is not reading it. I suspect that there might be an error in how I am handling the style
tag.
This is what the view looks like:
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="#{ <% @app.completion_status %> }" aria-valuemin="0" aria-valuemax="100" style="width: '#{raw(<%= number_to_percentage(@app.completion_status) %>)}';">
<%= @app.completion_status %>%
</div>
</div>
Upon closer inspection:
style="width: '#{raw(<%= number_to_percentage(@app.completion_status) %>)}';"
The value that needs to be converted to a percentage is: `33.3333333333333` (one third)
This is how the controller is set up:
def set_completion
@app = App.find(params[:id])
@app.update_attribute(:completion_status,
(((@app.elements.where(completion: true).count) / (@app.elements.count).to_f) * 100 )
)
end