Skip to content

Instantly share code, notes, and snippets.

@jmoren
Created August 16, 2012 12:31
Show Gist options
  • Save jmoren/3369826 to your computer and use it in GitHub Desktop.
Save jmoren/3369826 to your computer and use it in GitHub Desktop.
has many condition
has_many :tz_qcall_lists, :conditions => ["qcall_contacts_count > 0"], :dependent => :destroy
#qcalls_controller.rb
format.fxml { render :fxml => @qcall.to_fxml(
:only => [
:id,:name,:desc,:user_group_id,
:callerid_name,:callerid_phone,:msgset_abandon,
:duration_abandon,:total_calls,:abandon_calls,
:stats_call,:vmd,:poverride,:max_retry,
:start_calltime,:end_calltime,:wait_for,:ring_for
],
:include => {:qcall_contact_lists => {:only => [:id, :name], :include => {
:tz_qcall_lists => {
## :conditions => ['qcall_contacts_count > 0 '], => esto no anda
:only => [:qcall_contact_list_id, :id, :timezone, :active, :weight],
:methods => [:total_contacts, :connected_contacts, :left_to_call, :ratio, :calls_made]
}
}}},
:except => [:created_at,:updated_at],
:methods=> [
:total_contacts,:connected_contacts,
:calls_made,:stats_q,:stats_lead,
:stats_scheduled,:stats_dead,
:stats_graveyard,:stats_call,
:contacts_maxed,:contacts_tried,
:contacts_timeout,:stats_all
]
)}
@jmoren
Copy link
Author

jmoren commented Aug 16, 2012

tambien probe tener:
has_many :tz_qcall_lists, :dependent => :destroy
has_many :tz_qcall_lists_with_contacts, :conditions => ['qcall_contacts_count > 0']

Esto me funciono, pero hay que toquetear mucho en flex

@lucianopanaro
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment