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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:05:35+00:00 2026-06-03T03:05:35+00:00

So I have a model below that represents the situation: Students participate in Contests.

  • 0

So I have a model below that represents the situation:

  • Students participate in Contests.
  • Contests measure certain skills.
  • For each contest, each student gets a score for each skill measured.

Here are my models:

class Student < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
  attr_accessible :name
  has_and_belongs_to_many :skills
  has_many :contest_participations
  has_many :contests, :through => :contest_participations
  has_many :contest_scores, :through => :contests

end

class Skill < ActiveRecord::Base
  attr_accessible :name
  has_and_belongs_to_many :students
end

class Contest < ActiveRecord::Base
  attr_accessible :name, :contest_participations_attributes, :contest_scores_attributes
  has_many :contest_participations
  has_many :students, :through => :contest_participations
  has_many :contest_skills
  has_many :skills, :through => :contest_skills
  has_many :contest_scores
  accepts_nested_attributes_for :contest_participations, :contest_scores


end

class ContestParticipation < ActiveRecord::Base
  attr_accessible :contest_id, :student_id
  belongs_to :student
  belongs_to :contest
end

class ContestScore < ActiveRecord::Base
  attr_accessible :contest_id, :score, :skill_id, :student_id
  has_and_belongs_to_many :contests
  has_and_belongs_to_many :skills
  has_and_belongs_to_many :student
end

In my contests edit view, I’m trying to create a form, with formtastic, that will show all contest participants, and allow the user to add a score for each skill in the contest as follows.

But I get an error (student_id invalid symbol). How can I update the student scores?

<%= semantic_form_for @contest do |f| %>

    <%= f.input :name %>

    <%= @contest.students.each do |student| %>
         <%= @contest.skills.each do |skill| %>
               <%= f.inputs :name => "Scores", :for => :contest_scores do |scores_form| %>
                     <%= scores_form.input :student_id => "student.id" %>
                     <%= scores_form.input :skill_id => "skill.id" %>
                     <%= scores_form.input :score, :label => "Score" %>
               <% end %>
               <br />                 
         <% end %>
    <% end %>

    <%= f.actions do %>
         <%= f.action :submit, :as => :button %>
    <% 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-06-03T03:05:36+00:00Added an answer on June 3, 2026 at 3:05 am

    Try this. Added hidden because e think you don’t want ids to show up

    <%= scores_form.input :student_id, :as => :hidden, :value => student.id %>
    <%= scores_form.input :skill_id, :as => :hidden, :value => skill.id %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three model classes that look as below: class Model(models.Model): model = models.CharField(max_length=20,
I have two HeaderedContentControl s like those below that each have their content property
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
Lets say I have model inheritance set up in the way defined below. class
I have my entities as below. My data model enforces below and I cannot
I have model Article it has field title with some text that may contain
I have a model QuizAttempt that is going to check the result of a
I have a view model (below). public class TopicsViewModel { public Topic Topic {
I have an invoice model, that has many invoice items. I have a form
I have the following admin action below that exports data to a CSV file,

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.