Note that there are some explanatory texts on larger screens.

plurals
  1. POAttempt to call private method + conflict with the .rake file
    primarykey
    data
    text
    <p>I am Facing a weird error. Can any one explain me the reason for this..</p> <p>I have a model called Site, Settings and Experiences.</p> <p>Settings and Experiences has database column " <strong>bit</strong> "</p> <p>In my site model, I have this code </p> <pre><code> def populate_experiences_bit_set self.experiences.map(&amp;:bit).inject(0, :|) end def populate_settings_bit_set self.settings.map(&amp;:bit).inject(0, :|) end </code></pre> <p>In my rake file called 2_28.rake there is method called <strong>bit</strong></p> <pre><code> def bit(klass) current_class = klass.find(:all) if current_class.count == 0 return 1 else return (current_class.last.bit * 2) end end </code></pre> <p>This method is used in one of the rake task 'get_value' in the same rake file.</p> <p>Also another rake task called create_sites_report_data in the same file which has a line :</p> <pre><code>site.populate_experiences_bit_set </code></pre> <p>Now when i run rake task </p> <pre><code>rake releases:2.28:create_sites_report_data </code></pre> <p>I get an error stating </p> <blockquote> <p>" Attempt to call private method /Users/rakeshshetty/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-2.3.5/lib/active_record/attribute_methods.rb:236:in `method_missing' "</p> </blockquote> <pre><code>In console, this works fine &gt;&gt; s = Site/364 =&gt; #&lt;Site id: 364, name: "1 Field Ambulance - Detachment Wainwright", type: "Site", created_at: "2009-12-29 16:53:58", updated_at: "2009-12-29 16:53:58", short_name: "1 Field Am", self_updated_at: nil, last_updater_id: nil, vfp_id: "2BL0NFMI1", dup_reference_id: nil, field_id: nil, marked_as_deleted: false&gt; &gt;&gt; s.experiences.map(&amp;:bit).inject(0, :|) =&gt; 0 &gt;&gt; s.settings.map(&amp;:bit).inject(0, :|) =&gt; 64 </code></pre> <p>I replaced the method name in my 2_28.rake file from bit to bit_x Rake worked fine </p> <pre><code>blsi1181a:cpi_2.24 rakeshshetty$ rails -v Rails 2.3.5 blsi1181a:cpi_2.24 rakeshshetty$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.3.0] </code></pre> <p>My question is bit is a field in Settings and Experience. How does it call rake method function bit() ? Is this rake file loaded after the application is loaded?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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