Note that there are some explanatory texts on larger screens.

plurals
  1. PONested form error in Rails app
    primarykey
    data
    text
    <p>Models relevant to this question: user, friend, interest, person_interest. Person_interest is polymoprhic and can store interests that either belong to a user or a friend. </p> <p>Interests is pre-populated with approx. 30 interests. When a user registers they are asked to select their own interests, then lower in the form enter in their friends names select the interests of that person. </p> <p>Trying to achieve this with <code>&lt;%= friend_f.input :interests, :as =&gt; :check_boxes, :label =&gt; false %&gt;</code></p> <p>but getting the following error:</p> <pre><code>NoMethodError in User_steps#show Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/user_steps/show.html.erb where line #30 raised: undefined method `to_i' for []:ActiveRecord::Relation Extracted source (around line #30): 27: :end_year =&gt; Date.today.year - 12, 28: :order =&gt; [:month, :day, :year ] %&gt; 29: &lt;%= friend_f.input :gender, :collection =&gt; ['male','female'] %&gt; 30: &lt;%= friend_f.input :interests, :as =&gt; :check_boxes, :label =&gt; false %&gt; 31: &lt;%end%&gt; 32: 33: Rails.root: /Users/nelsonkeating/Desktop/ReminDeal Application Trace | Framework Trace | Full Trace app/views/user_steps/show.html.erb:30:in `block (2 levels) in _app_views_user_steps_show_html_erb__1202886937753978667_70281885932700' app/views/user_steps/show.html.erb:23:in `block in _app_views_user_steps_show_html_erb__1202886937753978667_70281885932700' app/views/user_steps/show.html.erb:1:in `_app_views_user_steps_show_html_erb__1202886937753978667_70281885932700' Request Parameters: {"id"=&gt;"show"} </code></pre> <p>And here's the form..</p> <pre><code>&lt;%= simple_form_for @user do |f| %&gt; &lt;%= f.input :name %&gt; &lt;%= f.input :city %&gt; &lt;%= f.input :address, :live =&gt; true %&gt; &lt;%= f.input :zipcode %&gt; &lt;%= f.input :date_of_birth, :as =&gt; :date, :start_year =&gt; 1900, :end_year =&gt; Date.today.year - 12, :order =&gt; [ :day, :month, :year] %&gt; &lt;%= f.input :gender, :collection =&gt; [:male, :female] %&gt; &lt;h4&gt;Select your top 3 interests..&lt;/h4&gt; &lt;%= f.association :interests, :as =&gt; :check_boxes, :label =&gt; false %&gt; &lt;h4&gt;What holidays do you celebrate?&lt;/h4&gt; &lt;%= f.association :holidays, :as =&gt; :check_boxes, :label =&gt; false %&gt; &lt;h4&gt;Add up to 10 friends birthdays that you would like to remember..&lt;/h4&gt; &lt;%= f.simple_fields_for :friends do |friend_f| %&gt; &lt;%= friend_f.input :name %&gt; &lt;%= friend_f.input :dob, :label =&gt; :Birthday, :as =&gt; :date, :start_year =&gt; Date.today.year - 90, :end_year =&gt; Date.today.year - 12, :order =&gt; [:month, :day, :year ] %&gt; &lt;%= friend_f.input :gender, :collection =&gt; ['male','female'] %&gt; &lt;%= friend_f.input :interests, :as =&gt; :check_boxes, :label =&gt; false %&gt; &lt;%end%&gt; &lt;%= f.button :submit, :class =&gt; 'btn btn-success' %&gt; &lt;%end%&gt; </code></pre> <p>Git repo is here: <a href="https://github.com/nelsonkeating/ReminDeal" rel="nofollow">https://github.com/nelsonkeating/ReminDeal</a></p>
    singulars
    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.
 

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