Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9034947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:37:36+00:00 2026-06-16T08:37:36+00:00

I followed this screencast to make a nested model form. http://railscasts.com/episodes/196-nested-model-form-part-1 Now, I am

  • 0

I followed this screencast to make a nested model form.
http://railscasts.com/episodes/196-nested-model-form-part-1

Now, I am trying my application to include such a nested model form but I received a argument error (wrong number of arguments(0 for 1)).

I can’t seem to figure out where I went wrong and would like to seek some advice on what I could try out and why some an error might have occurred.

The error happens on this line in the Subject Model.

has_many :lessons, :dependent => destroy

The other relevant codes:

Subjects Controller:

  def new
    @subject = Subject.new
    #3 times one for lecture one for lab one for tut.
    3.times{@subject.lessons.build}

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @subject }
      format.js
    end
  end

Subject Model

class Subject < ActiveRecord::Base
  has_many :lessons, :dependent => destroy
  attr_accessible :lesson_attributes, :acad_unit, :cohort_size, :discipline, :remarks, :subject_code, :subject_name, :year_of_study
  accepts_nested_attributes_for :lessons, :reject_if => lambda { |a| a[:lesson_type].blank? }, :allow_destroy => true
end

Lesson Model

class Lesson < ActiveRecord::Base
  belongs_to :subject
  attr_accessible  :frequency, :lesson_type, :no_of_lesson, :possible_venues
end

_form.html.erb

    <%= form_for(@subject,:remote=>true) do |f| %>
  <% if @subject.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@subject.errors.count, "error") %> prohibited this subject from being saved:</h2>

      <ul>
      <% @subject.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :subject_code %><br />
    <%= f.text_field :subject_code %>
  </div>
  <div class="field">
    <%= f.label :subject_name %><br />
    <%= f.text_field :subject_name %>
  </div>
  <div class="field">
    <%= f.label :year_of_study %><br />
    <%= f.text_field :year_of_study %>
  </div>
  <div class="field">
    <%= f.label :discipline %><br />
    <%= f.text_field :discipline %>
  </div>
  <div class="field">
    <%= f.label :acad_unit %><br />
    <%= f.text_field :acad_unit %>
  </div>
  <div class="field">
    <%= f.label :cohort_size %><br />
    <%= f.text_field :cohort_size %>
  </div>
  <div class="field">
    <%= f.label :remarks %><br />
    <%= f.text_field :remarks %>
  </div>

  <ol>
  <%= f.fields_for :lessons do |builder| %>
    <%= render "lesson_fields", :f => builder %>
  <% end %>
  </ol>

<% end %>

_lesson_fields.html.erb

<p>
<div class="field">
    <%= f.label :lesson_type %><br />
    <%= f.text_field :lesson_type %>
  </div>
  <div class="field">
    <%= f.label :no_of_lesson %><br />
    <%= f.text_field :no_of_lesson %>
  </div>
  <div class="field">
    <%= f.label :frequency %><br />
    <%= f.text_field :frequency %>
  </div>
  <div class="field">
    <%= f.label :possible_venues %><br />
    <%= f.text_field :possible_venues %>
    </div>
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:37:38+00:00Added an answer on June 16, 2026 at 8:37 am

    I guess you wanted :

    has_many :lessons, :dependent => :destroy
    

    ?

    Here you’ll find a nice discussion on topic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this screencast to make a erb:to:haml rake task: http://teachmetocode.com/screencasts/creating-a-rake-task-to-convert-erb-to-haml/ I backed everything
I followed this post http://neurochannels.blogspot.com/2010/05/how-to-run-r-code-in-matlab.html , to install R(D)Com server in order to call
I followed this tutorial http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html I wrote the manifest File giving all the permissions
I followed this tutorial http://stevejenkins.com/blog/2011/08/how-to-install-apc-alternative-php-cache-on-centos-5-6/ to install apc on my centos vps hosting but
I followed this tutorial and the source code : http://blog.objectgraph.com/index.php/2010/04/20/encrypting-decrypting-base64-encode-decode-in-iphone-objective-c/ And then, I downloaded
I followed this tutorial : http://blog.mugunthkumar.com/coding/iphone-tutorial-how-to-send-in-app-sms/ and I got the alert 'Text messaging is
I followed this tutorial: http://www.wikihow.com/Generate-Hibernate-Pojo-Classes-from-DB-Tables After I click finish, it looks like something is
I followed this link http://wiki.developerforce.com/page/Getting_Started_with_the_Mobile_SDK_for_iOS#Working_with_the_SDK to as to integrate my iOS App with the
I followed this tutorial: http://php.about.com/od/finishedphp1/ss/rating_script.htm but when i run it i get Notice: Undefined
I followed this http://jsfiddle.net/6rSvf/ to make the links change div content when clicked. However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.