Skip to content

Instantly share code, notes, and snippets.

View masterkain's full-sized avatar
🤖

Kain masterkain

🤖
View GitHub Profile
module Administration::ReportsHelper
def add_reason_link(name)
link_to_function name do |page|
page.insert_html :bottom, :reasons, :partial => 'reason', :object => Reason.new
end
end
end
// $('element').setupAuto("/administration/reasons.js")
$.fn.setupAuto = function(url) {
$(this).autocomplete(url, {
width: 620,
max: 10,
highlight: false,
scroll: true,
scrollHeight: 300
});
}
@masterkain
masterkain / report.rb
Created September 3, 2008 17:01
strange behaviour on saving rich join attributes
class Report < ActiveRecord::Base
has_many :report_parameters
has_many :parameters, :through => :report_parameters do
def push_with_attributes(monitored_parameter, rich_join_attributes)
ReportParameter.send(:with_scope, :create => rich_join_attributes) { self << monitored_parameter }
end
end
# "report_parameter_attributes"=>[{"value"=>"10", "parameter_id"=>"14"}]
>> Dictionary.first.attributes.values
=> ["ciao", 1, "hello"]
AVAILABLE_LOCALES = Dir.new(LOCALES_DIRECTORY).entries.collect {|x| x =~ /\.yml/ ? x.sub(/\.yml/,"") : nil }.compact.each_with_object({}) { |str, hsh| hsh[str] = YAML.load_file(LOCALES_DIRECTORY+str+".yml")[str]["this_file_language"] }.freeze
class Patient < ActiveRecord::Base
has_many :documents
has_many :reports, :through => :documents do
def find_for_parameter(parameter)
# report hm parameters
find(:all, :joins => :parameters, :conditions => ['parameters.id = ?', parameter.id])
end
end
# @patient.reports.find_for_parameter(Parameter.first)
class Report < ActiveRecord::Base
has_many :report_reasons
has_many :reasons, :through => :report_reasons
validates_associated :reasons
end
class Reason < ActiveRecord::Base
has_many :report_reasons
has_many :reports, :through => :report_reasons
def self.available_languages_codes
codes = []
available_languages_columns.each do |column|
codes << column.to_s.gsub(/content_/, '')
end
codes
end
has_many :documents, :through => :contributions, :select => "documents.*, join_table.rich_attribute" do
def push_with_attributes(document, rich_join_attrs)
Contribution.send(:with_scope, :create => rich_join_attrs) { self << document }
end
end
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true />
<key>Label</key>
<string>com.mysql.mysqld</string>
<key>Program</key>
<string>/usr/local/mysql/bin/mysqld_safe</string>