Technical
Chic Crams

Flipper Based on nil or not

I had a situation when I needed to set either stringValue or numericValue having only one field for both. I solved it like that:


   <%= @ovr.nvalue ||= @ovr.svalue %>

Submit tag with confirm


<%= submit_tag "Delete",
                     :style => "font-size:11px",
                     :onclick => "if (!confirm('Are You Sure?')) return false; this.form.submit()" %>

flash[:notice] on multiple records

I had a scenario where I had multiple records on one page, and an update operation per each record.

So i did the following:

View


<div id="notice">
 <%= flash["update_notice_#{@settlement.settleInstrId.to_i}".to_sym] %>
</div>

Controller


flash["update_notice_#{params[:id]}".to_sym] = "Record was updated successfully"