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

  • Home
  • SEARCH
  • 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 3214612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:04:53+00:00 2026-05-17T15:04:53+00:00

I have a complex form for scheduling events. Here are the abbreviated associations: class

  • 0

I have a complex form for scheduling events. Here are the abbreviated associations:

class Event < ActiveRecord::Base
  belongs_to :client
  accepts_nested_attributes_for :client, :reject_if => lambda { |a| a[:name].blank? }
end

class Client < ActiveRecord::Base
  has_many :events
  has_many :questions, :dependent => :destroy
  accepts_nested_attributes_for :questions, :reject_if => lambda { |a| a[:content].blank? }
end

The form is creating a new event and I have the following structure:

- form_for @event do |event_form|
    %select=collection_select(client_options_for_select, :options, :group_name, :id, :name, @event.client_id)

   - event_form.fields_for :client do |client|
     = client.text_field :name

     - client.fields_for :questions do |question|
       = question.text_field :content

The client already exists and is chosen from a select menu. An observer renders the nested attributes form by setting the client variable in a controller action and then rendering the partial.

Here is the error I’m getting:

ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #1 of app/views/proceedings/_questions.html.haml:
1: - event_form.fields_for :client do |client|

app/views/proceedings/_questions.html.haml:1:in `form'
app/views/proceedings/_questions.html.haml:1:in `_run_haml_app47views47events47_client_questions46html46haml_locals_client_questions_object'
haml (3.0.21) rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
app/controllers/proceedings_controller.rb:261:in `__instance_exec0'
app/controllers/proceedings_controller.rb:260:in `corp_client_questions'
app/controllers/proceedings_controller.rb:258:in `corp_client_questions'

I’m having problems (I think) with the belongs_to association between Event and Client. I don’t know if Event can accept nested attributes of Client when the Event belongs_to the Client. I’ve always done it the other way around (Client accepts nested attributes of Event).

Any ideas? I can elaborate if you need more code or background. Thanks!

Update: Added controller code as requested.

def client_questions
if params[:client_id].blank?
  render_no_client_questions
elsif @client = Client.find(params[:client_id]) and @client.is_unspecified?
  render_no_client_questions
else
  respond_to do |format|
    format.js {
      render :update do |page|
        page[:client_questions].replace_html :partial => 'client_questions', :layout => false
      end
    }
  end
end

end

  • 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-05-17T15:04:53+00:00Added an answer on May 17, 2026 at 3:04 pm

    try adding an instance of the fields_for object in the options… generally a symbol isn’t enough when creating a new top-level form object… Try the following, but yes it is possible to accept nested attributes on a belongs_to.

    <%= event_form.fields_for :client, @client do |client| %>
      <%= client.text_field :name %>
      <%= client.fields_for :questions, Question.new do |question| %>
        <%= question.text_field :content %>
      <% end %>
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a complex form in Ruby on Rails 2.3.5, here's the structure for
Well i have a complex form view model like this : public class TransactionFormViewModel
I have a complex form that has a static section and one that can
I have a complex form to allow the user to configure my app. What's
I have a complex form for a model Schedule that belongs to a parent
I have two complex dictionaries in the form Dictionary<string, Dictionary<string, Dictionary<string, List<string>>>> So as
I have a pretty complex form that provides real-time validation and feedback to the
I have a complex input form within a PHP based web application. To structure
I have a complex html-Form and am using jQ for some of the work
I have a pretty complex form with lots of inputs and validators. For the

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.