Skip to content

Instantly share code, notes, and snippets.

View ColPanic's full-sized avatar

ColPanic ColPanic

View GitHub Profile
<p>
<form name="sform" action="" style="display:inline;">
<label for="item_name">Filter on item name : </label>
<%= text_field_tag("query", params['query'], :size => 10 ) %>
</form>
<%= image_tag("spinner.gif",
:align => "absmiddle",
:border => 0,
:id => "spinner",
@ColPanic
ColPanic / gist:788795
Created January 20, 2011 22:14
How far into hell am I going?
@esi_dev = Kernel.const_get("Esi#{self.model_name}").new(@device.attributes.delete_if{|k,v|!Kernel.const_get("Esi#{self.model_name}").respond_to?(k)})
@ColPanic
ColPanic / gist:788808
Created January 20, 2011 22:22
I un-KLCannonized it... this looks ok, yeah?
# This will associate ANY device type with an ESI and create the
# associated EsiDeviceType record properly populated.
def add_device
#Look up device to add
@device = Kernel.const_get(self.model_name).find(params[:id])
#Ok, this line is some serious black magic and needs explained...
# 1. Extract the name of the model (device type)
The object:
EsiElectricMeter(esi_electric_meter_id: integer, electric_meter_id: integer, esi_id: integer, device_mq_id: integer, name: string, status: string, comments: text, active_flag: string, delete_flag: string, initial_meter_reading: integer, final_meter_reading: integer, meter_reading_delta: integer, submeter_flag: string, ct_factor: integer, esi_electric_meter_history_id: integer, date_created: timestamp, date_updated: timestamp)
irb(main):126:0* EsiElectricMeter.respond_to?("esi_electric_meter_id")
=> false
irb(main):127:0>
irb(main):128:0* EsiElectricMeter.respond_to?("electric_meter_id")
=> false