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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T14:37:58+00:00 2026-06-02T14:37:58+00:00

I need some help with handling validations with Twitter Bootstrap properly. The validations are

  • 0

I need some help with handling validations with Twitter Bootstrap properly. The validations are working properly, the issue is Twitter Bootstrap Flash screen. This is what I mean:

No fields filled out and submitted returns: https://i.stack.imgur.com/8pvUc.png

The 2 of the required 4 fields submitted returns: https://i.stack.imgur.com/J6lCi.png
(notice that it doesn’t flash the errors)

I have a basketball app where a Player can be on many Rosters(for player roster archiving purposes) and a Roster can have many Players.

Roster.rb

class Roster < ActiveRecord::Base
  belongs_to :team
  has_many :rosterizes
  has_many :players, :through => :rosterizes
  accepts_nested_attributes_for :players
  validates_presence_of :jersey_number, :class_year
  attr_accessible :jersey_number, :class_year, :players, :team_id, :players_attributes
end

Rosterizes.rb(poorly named I know…)

class Rosterize < ActiveRecord::Base
  belongs_to :player
  belongs_to :roster
  attr_accessible :player_id, :roster_id
end

Player.rb

class Player < ActiveRecord::Base
  has_many :rosterizes
  has_many :rosters, :through => :rosterizes
  validates_presence_of :first_name, :last_name
  attr_accessible :first_name, :last_name, :active
end

_add_player_form.html.erb
(nested form)

<%= simple_nested_form_for @roster, :url =>player_added_team_path, :html => { :class => 'form-horizontal' } do |f| %>   
    <%= f.simple_fields_for :players, @roster.players.build do |x| %>
        <%= x.input :first_name %>
        <%= x.input :last_name %>
        <%= x.input :active, :as => :hidden, :input_html => {:value => true} %>
    <%end%>
    <%=f.input :class_year %>       
    <%=f.input :jersey_number %>
    <%=f.input :team_id, :as => :hidden, :input_html => {:value => params[:id]}%>

    <div class="well">
    <%= f.button :submit, :class => 'btn-primary icon-plus-sign btn-success', :value => "Add To Team" %>
    </div>
<%end%>

Thanks for the help in advance!

SOLUTION

My problem is that every time the view was loaded, it was building a new form, thus never getting back the errors on the rollback

I made a change to my controller that builds for the nested form

Controller

def add_player
     ...
     @new_player = @roster.players.build
end

And made the change accordingly to the view

_add_player_form.html.erb

<%= f.simple_fields_for :players, @new_player do |x| %>
     ...

<%end%>

This did the trick, thanks Mober!

  • 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-02T14:38:01+00:00Added an answer on June 2, 2026 at 2:38 pm

    the reason why only the first level validation is shown an the associated not is fairly simple… You do a <%= f.simple_fields_for :players, @roster.players.build do |x| %> which buildes the association ALWAYS new when the sites’s rendered. What you want to is building the association only if it does not exists yet…

    <% @roster.players.build if !@roster.players %>
    <%= f.simple_fields_for :player do |player_form| %>
    ...
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help gathering thoughts on this issue. Our team is moving ahead with
Need some help to solve this. I have a gridview and inside the gridview
Need some help with this problem in implementing with XSLT, I had already implemented
I do some postdata handling on my webpage, but need some help with the
I am a Java programmer working with C++ code, and need some help with
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
Need some help assigning a mouseover event to display some icons that start out
Need some help with a query.. I have three tables. Source id name 1
Need some help with DataFormatString in GridView. I have a Double value that needs

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.