ruby on rails - Refactor repetitively progress-bar's code segment -


i showing progress bar user tasks needs finishing profile.

i have code-segment on several html.erb files:

  <% if progress < 100 %>   <div>       <div class="progress progress-info progress-striped active">       <div class="bar" style="width: <%= progress %>%"></div>     </div>      <div align="right"><u>next</u>: <%=link_to nextusertask, determinedpath %></div>   </div>   <% end %> 

i think ugly repeat code on these files. there way refactor this? example putting application_helper...

i tried not sure how handle html in there.

thanks

you put in partial, example shared/_progress_bar.html.erb , render with:

<%= render 'shared/progress_bar', progress: progress, nextusertask: nextusertask, determinedpath: determinedpath %> 

more partials:

http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -