ruby - Rails loading modals -


i have views require lot of partials, in turn require several bootstrap modals work correctly.

however, loading modals bit painful, because if load them in wrong tag, can screw them up, , duplicate them.

i'd have nice helper load_modal, save list of modals need loaded. then, in part of html of choosing, can choose iterate on list load partials

my problem

how can store list of partials called arguments ?

i have thought of following, (deliberately using non-working syntax didn't know how otherwise)

application_helper.rb

# input should  # => 'path_to_partial', {locals} def load_modal(*args)   unless (@modals ||= []).include?(args.first)     @modals << args   end end 

some_partial.html.erb

<% load_modals('project/deadline', project: @project) %> 

application.html

<% if @modals     @modals.each |modal| %>         <%= render(modal) %>     <% end %> <% end %> 

note : current error code

'"project/deadline"' not activemodel-compatible object. must implement :to_partial_path. 

this seems work

application_helper.rb

  def load_modal(*args)     unless (@modals ||= []).include?(args.first)       @modals.push(*args)     end   end 

application.html.erb

<% if @modals     @modals.each |modal_with_args| %>       <%= render(modal_with_args) %>     <% end %> <% end %> 

Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -