Note that there are some explanatory texts on larger screens.

plurals
  1. POfields_for text_field doesn't support string data type
    primarykey
    data
    text
    <p>I am examining the complex_form_example project on github. I modified the migration file so that :content changed from t.text to t.string (as shown below): <strong>Please notice that t.string is the only place I changed in the github example project and before the change it all worked.</strong> </p> <pre><code>class CreateQuestions &lt; ActiveRecord::Migration def self.up create_table :questions do |t| t.integer :survey_id t.string :content ##t.text :content t.timestamps end end def self.down drop_table :questions end end </code></pre> <p>Here is the nested_form_for code:</p> <pre><code>&lt;%= nested_form_for @survey do |f| %&gt; &lt;%= f.error_messages %&gt; &lt;p&gt; &lt;%= f.label :name %&gt;&lt;br /&gt; &lt;%= f.text_field :name %&gt; &lt;/p&gt; &lt;%= f.fields_for :questions, :questions do |g|%&gt; &lt;p&gt; &lt;%= g.label :content, "Question" %&gt;&lt;br /&gt; &lt;%= g.input :content, :rows =&gt; 3 %&gt;&lt;br /&gt; &lt;%= g.link_to_remove "remove" %&gt; &lt;/p&gt; &lt;%= g.fields_for :answers %&gt; &lt;p&gt;&lt;%= g.link_to_add "Add an answer", :answers %&gt;&lt;/p&gt; &lt;% end %&gt; &lt;p&gt;&lt;%= f.link_to_add "Add a question", :questions %&gt;&lt;/p&gt; &lt;p&gt;&lt;%= f.submit "Submit" %&gt;&lt;/p&gt; &lt;% end %&gt; </code></pre> <p>And now I get the following error message:</p> <pre><code>undefined method `content' for :questions:Symbol Extracted source (around line #10): 7: &lt;%= f.fields_for :questions, :questions do |g|%&gt; 8: &lt;p&gt; 9: &lt;%= g.label :content, "Question" %&gt;&lt;br /&gt; 10: &lt;%= g.text_field :content, :rows =&gt; 3 %&gt;&lt;br /&gt; 11: &lt;%= g.link_to_remove "remove" %&gt; 12: &lt;/p&gt; 13: &lt;%= g.fields_for :answers %&gt; </code></pre> <p>My question is, is there a fields_for field name that supports string type directly?</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.
    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