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 6773797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:42:39+00:00 2026-05-26T15:42:39+00:00

I have this structure models class Tournament < ActiveRecord::Base AGES = [5u, 6u, 7u,

  • 0

I have this structure models

class Tournament < ActiveRecord::Base
  AGES = ["5u", "6u", "7u", "8u"]
  has_many  :courts, :dependent => :destroy
  accepts_nested_attributes_for :courts, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true

class Court < ActiveRecord::Base
  belongs_to :tournament, :autosave => true
  has_many  :ages, :dependent => :destroy
  accepts_nested_attributes_for :ages, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true

class Age < ActiveRecord::Base
  belongs_to :court

Now my forms look like this

_form.html.erb

<%= semantic_form_for @tournament do |f| %>
<%= f.inputs do %>
  <%= f.input :name, :hint => "What is the name of the Tournament?" %>
<%= f.semantic_fields_for :courts do |builder| %>
       <%= render :partial => "court_fields", :locals => { :f => builder } %>
   <% end %>

_court_fields.html.erb

<div class="nested_fields">
<%= f.input :name, :input_html => {:class => "name"} %>
<%= f.semantic_fields_for :ages do |builder| %>
  <%= render :partial => "age_fields", :locals => { :f => builder } %>
<% end %>

_age_fields.html.erb

 Testing ...am I getting in here
<%= f.input :name, :as => :check_boxes, :collection => Tournament::AGES, :input_html => {:class => "age_limits"} %>

everything seems to work well except nothing shows up in the ages_fields partial…not the checkboxes and not even the dummy text Testing ...am I getting in here is not displaying….any ideas what could be causing the issue

  • 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-26T15:42:39+00:00Added an answer on May 26, 2026 at 3:42 pm

    The obvious reason I can think of: are you sure your Court has ages ?

    [EDIT] That the Court has the relation was indeed clear to me.
    But your code will only show an age for a court if it already exists.

    From your output in the comments: the court has no actual ages so no ages are shown.

    If you do this in your controller:

    def new
      @tournament = Tournament.new
      @tournament.courts.build
      @tournament.courts[0].ages.build  
    end
    

    This will make sure that you have at least one (empty) court and one (empty) age.

    Otherwise you could also consider using a gem like cocoon to dynamically add new elements if needed.

    Hope this helps.

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

Sidebar

Related Questions

I have a data structure that looks like this (simplified version) class A(models.Model): a
I have this structure of model objects: Class A: b = models.ManyToManyField(B) Class B:
I have the following two models: class Message < ActiveRecord::Base belongs_to :to_user, :class_name =>
I have this structure on form, <input type=test value= id=username /> <span class=input-value>John Smith</span>
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
Okay so, I have this project structure: package A.B class SuperClass (this class is
I have the following structure: class FeatureType(models.Model): type = models.CharField(max_length=20) def __unicode__(self): return self.type
Given a model structure like this: class Book(models.Model): user = models.ForeignKey(User) class Readingdate(models.Model): book
Let's say I have a class structure that is defined below: Class Item(models.Model): ...
I have the following model structure below: class Master(models.Model): name = models.CharField(max_length=50) mounting_height =

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.