This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"value"=>"10", "parameter_id"=>"14"}, {"value"=>"2", "parameter_id"=>"14"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conditions = Where.new | |
conditions.or('accounts.phone like ?', '%' + params[:search] + '%') unless params[:search].blank? | |
conditions.or('groups.name like ?', '%' + params[:search] + '%') unless params[:search].blank? | |
# new rails feature, :joins permit to have conditions based on the joined table. | |
# http://ryandaigle.com/articles/2008/7/7/what-s-new-in-edge-rails-easy-join-table-conditions | |
@accounts = Account.paginate(:page => params[:page] || 1, :joins => :group, :conditions => conditions, :include => :group) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> Dictionary.first.attributes.values | |
=> ["ciao", 1, "hello"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".reason_content").livequery( | |
function() { | |
// var url = $(this).attr('autocomplete_url'); | |
$(this).autocomplete("/administration/reasons.js"); | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="#" onclick="try { | |
$("#diagnoses").append("<div class=\"diagnosis\">\n\t<dl class=\"form\">\n\t\t\n\t\t<dt class=\"optional\">Name </dt>\n\t\t<dd>\n\t\t\t<input autocomplete=\"off\" id=\"report_diagnosis_attributes__name\" name=\"report[diagnosis_attributes][][name]\" size=\"30\" type=\"text\" /> \n\t\t\t<a class=\"remove_diagnosis\" href=\"#\">remove</a>\n\t\t</dd>\n\t\t\n\t</dl>\n</div>"); | |
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('$(\"#diagnoses\").append(\"<div class=\\\"diagnosis\\\">\\n\\t<dl class=\\\"form\\\">\\n\\t\\t\\n\\t\\t<dt class=\\\"optional\\\">Name </dt>\\n\\t\\t<dd>\\n\\t\\t\\t<input autocomplete=\\\"off\\\" id=\\\"report_diagnosis_attributes__name\\\" name=\\\"report[diagnosis_a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $('element').setupAuto("/administration/reasons.js") | |
$.fn.setupAuto = function(url) { | |
$(this).autocomplete(url, { | |
width: 620, | |
max: 10, | |
highlight: false, | |
scroll: true, | |
scrollHeight: 300 | |
}); | |
} |