Note that there are some explanatory texts on larger screens.

plurals
  1. PO"language" attribute on Rails ActiveRecord model
    primarykey
    data
    text
    <p>I'll try to figure out some strange behaviour from a ActiveRecord model. The model have a <code>language</code> field, which is filled with a language identifier ("de", "en")</p> <p>If I want to access the language attribute from the from a model object, I'll get <code>nil</code>.</p> <pre><code> $&gt; foo = Product.first =&gt; #&lt;Product id: 1049488, ... , language: "en", ...&gt; $&gt; foo.id =&gt; 1049488 $&gt; foo.language =&gt; nil $&gt; foo.send("language") =&gt; nil $&gt; foo.to_yaml =&gt; "--- !ruby/object:Product \nattributes: \n ... language: en\n ..." $&gt; foo.language =&gt; "en" </code></pre> <p>It seems like a hidden lazy loading "feature" or something else is trying to interventing here. Is it the field name "language" which causes this behaviour or is there some other mechanism which I dont understand?</p> <p>I use the following Gems inside my Rails project:</p> <ul> <li>rails 3.0.0</li> <li>jquery-rails</li> <li>sqlite3-ruby</li> <li>mysql</li> <li>rmagick</li> <li>acts_as_tree</li> <li>dbi</li> <li>dbd-odbc</li> <li>solr-ruby</li> <li>progressbar</li> </ul> <p>I've also checked various "<a href="http://latheesh.com/2010/02/02/rails-reserved-words/" rel="nofollow">reserved words</a>" list for collisions but no list has <code>language</code> on it. When the column name will be changed to <code>lang</code>, everything works fine. So, it <em>is</em> a naming problem, but I can't track it down. Are there any tools to get a call-stack or something else from a given method in Ruby to locate the problem?</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