Rails when does flash get set -


given following view code, if user not click button 'add wo attachment' - let's hit cancel instead. should flash[:workorder_id] nil?

<div class="tab-pane" id="tabs-8">   <%= render 'filtered7' %>   <% if @workorder.not_closed? %>       <%= link_to 'add wo attachment', new_attachment_path, :class => 'btn btn-primary', :onclick => flash[:workorder_id] = @workorder.id %>   <% end %> </div> 

i believe gets set if don't click on button. , seems wrong me.

the onclick attribute needs contain javascript executed client. if need set flash message, need make request, not doing.

this have effect of adding onclick="1" html if @workorder.id 1, set flash regardless of being clicked because of how you're forcing assignment.

if need set flash conditionally, need make assignment in whatever handles new_attachment_path, presumably new method of attachmentscontroller.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -