javascript - Ruby On Rails: how can I render a partial inside a loop using js.haml? -
i'm trying render partial every object in array of hashes:
my controller:
@active, @not_active = @objects.partition{ |obj| obj['active'] == 'true' }
my js.haml
file:
# code works - @active.each |obj| $('#' + "#{obj['id']}").remove(); # remove row # code doesn't work - @not_active.each |obj| -p obj # prints object $('#' + "#{obj['id']}").html("#{escape_javascript(render :partial => 'objects/not_active', :locals => {:obj => obj})}");
this code should redraw of existing rows in table. in partial obj = [ ] instead of hash..
how else can render partial inside ruby loop?
there's more concise way render partials , pass data it:
render 'objects/not_active', obj: obj
not sure if rails 4 only.
Comments
Post a Comment