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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:12:46+00:00 2026-06-10T10:12:46+00:00

I have a Report with many nested Value objects: Report class class Report <

  • 0

I have a Report with many nested Value objects:

Report class

class Report < ActiveRecord::Base
  attr_accessible :comments
  has_many :values
  accepts_nested_attributes_for :values
end

Value class

class Value < ActiveRecord::Base
  attr_accessible :value, :assessed_user_id, :behaviour_id

  belongs_to :assessed_user
  belongs_to :behaviour

  belongs_to :report

end

I need a form that will accept a Report with its associated matrix of Value objects like so:

| User | Behaviour1 | Behaviour2 | Behaviour3 |
| Bob  |     ___    |    ___     |    ___     |
| Jane |     ___    |    ___     |    ___     |
| Jill |     ___    |    ___     |    ___     |

I’m new to rails and I’ve read all about nested attributes and I’ve tried a million variations on semantic_form_for and possibilities with formtastic, but I cannot seem to place the proper value.value objects in their right places or to set their behaviour and assessed_user as hidden fields, but I cannot seem to get this to work.

The following shows what are supposed to be hidden fields and I cannot get my create (follows) to accept it. Also, I don’t see any indexes on the sub-form elements:

<%= semantic_form_for @report do |f| %>
  <table>
    <tr>
      <th>User</th>
    <% @behaviours.each do |behaviour| %>
      <th><%= behaviour.name %></th>
    <% end %>
    </tr>
    <% index = 0 %>
    <% @members.each do |member| %>
      <tr>
        <td><%= member.first_name %> <%= member.last_name %></td>
        <% @behaviours.each do |behaviour| %>
          <% @report.values[index].behaviour_id = behaviour.id %>
          <% @report.values[index].assessed_user_id = member.id %>
          <td>

              <%= f.inputs :behaviour_id, :as => :hidden, :for => @report.values[index] %>
              <%= f.inputs :assessed_user_id, :as => :hidden, :for => @report.values[index] %>
              <%= f.inputs :value, :for => :values, :for => @report.values[index] %>
              <% index = index + 1  %>
          </td>
        <% end %>
      </tr>
    <% end %>  

  </table>
  <%= f.inputs :comments %>

  <%= f.buttons %>
<% end %>

reports_controller.rb

def create
  @report = Report.new( params[:report] )
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-10T10:12:47+00:00Added an answer on June 10, 2026 at 10:12 am

    You can have a look on this Railscate esp
    http://railscasts.com/episodes/196-nested-model-form-part-1

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

Sidebar

Related Questions

I have a report in which I want to display value of 2 engineers
I have a simple has_many/belongs_to relationship between Report and Chart. The issue I'm having
Similar to this question , but I have one master report which contains many
For example, you may have a report that joins on many tables, but in
I have a report to build that has many different fields showing various results.
I have a VB active report which has many different attributes. The report contains
I have a report with several sections. Many of these sections have a paragraph
I have report_controller where I have two objects, @report and @reporte, and I want
I have a report that is getting info from bsis, bsas, bsid, bsad, vbrk,
I have a report like this person | lead count | support count |

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.