Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use has_many :through and in_place_edit?
    text
    copied!<p>I have two Models: Campaign and Contact.</p> <p>A Campaign has_many Contacts.</p> <p>A Contact has_many Campaigns.</p> <p>Currently, each Contact has a contact.date_entered attribute. A Campaign uses that date as the ate to count down to the different Events that belong_to the Campaign.</p> <p>However, there are situations where a Campaign for a specific Contact may need to be delayed by X number of days. In this instance, the campaigncontact.delaydays = 10.</p> <p>In some cases, the Campaign must be stopped altogether for the specific Contact, so for now I set campaigncontact.delaydays = 1. (Are there major problems with that?)</p> <p>By default, I am assuming that no campaigncontact exists (but not sure how that works?)</p> <p>So here's what I've tried to do:</p> <pre><code>class Contact &lt; ActiveRecord::Base has_many :campaigncontacts has_many :campaigns, :through =&gt; :campaigncontacts end class Campaign &lt; ActiveRecord::Base has_many :campaigncontacts has_many :contacts, :through =&gt; :campaigncontacts end script/generate model campaigncontact campaign_id:integer contact_id:integer delaydays:integer class Campaigncontact &lt; ActiveRecord::Base belongs_to :campaign belongs_to :contact end </code></pre> <p>So, here's the question: Is the above correct? If so, how do I allow a user to edit the delay of a campaign for a specific Contact.</p> <p>For now, I want to do so from the Contact View.</p> <p>This is what I tried:</p> <p>In the Contact controller (?)</p> <pre><code> in_place_edit_for :campaigncontact, column.delaydays </code></pre> <p>And in the View</p> <pre><code>&lt;%= in_place_editor_field :campaigncontact, :delaydays %&gt; </code></pre> <p>How can I get it right?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload