The recipients are either:
everybody - the all checkbox
or
one or more of the klasses
or
one or more of the roles
I have the relationships understod this way. Perhaps I'm wrong.
The emails are from Mailings.
Emails reference the sender - hence they belong_to :user
Emails are sent to one or more klasses. The reference to which klasses
to deliver the email goes with the email so
mailings belongs_to :klasses
Roles is the same story - they also are stored with the email and
thereforem
Mailings belongs_to :roles
Surely both klasses and roles has a has_many :mailings but is that going
to help us here.
Agree - or am I just completely off.
/S
Sergio Cambra .:: entreCables S.L. ::. wrote:
> On Viernes, 11 de Septiembre de 2009 06:32:19 Soren Christensen escribió:
>
>> Hi,
>>
>> I have an application where I need to select the recipients of an e-mail.
>> I do this using a combination of the following:
>>
>> - a checkbox to deliver to all
>> - a multiple select to select a set of groups
>>
>> This is currently done with AS - Wondering if this is the best solution.
>>
>> 3 questions:
>>
>> 1) I use this to build the multiple select boxes. They store their
>> values fine in the database, but nothing is selected when I edit them.
>> Has anybody gotten this to work correctly:
>>
>> def klass_ids_form_column(record, input_name)
>> select_tag("record[klass_ids][]",
>> options_for_select(Klass.find(:all).sort { |a,b|
>> a.name.casecmp(b.name)}.collect {|p| [ p.to_label, p.id ] },
>> record.klass_ids.collect { |cr| cr.id}), {:multiple=>true,
>> :size=>6}) end
>>
>> 2) Rather than having a multiple select box I would like a set of check
>> boxes. Much more obvious user interface
>>
>> is there a simple way to do this ?
>>
>
> recipients is an association? ActiveScaffold has builtin functionality for
> showing checkboxes in has_many or habtm associations.
>
>
>> or can the code in 1) be converted like:
>>
>> def klass_ids_form_column(record, input_name)
>>
>> Klass.find(:all).sort { |a,b| a.grade <=> b.grade}.each do |kl|
>> check_box_tag("record[klass_ids][]", "#{kl.id}",
>> record[klass_ids].include?(kl.id))
>> end
>> end
>>
>> 3) And for the really nice version:
>> Make 2) work, but use AJAX to show/remove the second level of checkboxes
>> - they are only shown if all is not checked.
>>
>
> You can add a onclick method to the checkbox, in that function hide the
> element which has the checkboxes, and uncheck all the checkboxes, when it's
> checked, and show that element when it's unchecked.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---