Has_many :through , extra data retrieval

I have a has_many :through companies <-> markets with emails as the
join table.

The view is relatively easy:

<% form_for :market, :html => { :id => ‘marketform’ } do |f|%>
<%= hidden_field_tag “company[companyid]”, @company.id, :index =>
@company.id %>
<% for market in @markets %>


<%= check_box_tag “company[market_attributes][]”, market.id,
@company.markets.include?(market) %>
<%= label_tag :market_ids, market.name.upcase -%>
<%= text_field_tag “emaildistro[#
{market.id}]” %>


<% end %>

<% end %>

controller:

company = Contactcompany.find(params[:company][:companyid])
markets = params[:company][:market_attributes] ||= []
company.market_ids = markets
company.emails.each{|mail|
distro = params[:emaildistro]["#{mail.market.id}"]
mail.update_attributes(:emaildistro => distro)
}

Is there a way to retrieve the emails just like the checkboxes do when
you pull up the view?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs