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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:38:27+00:00 2026-05-27T23:38:27+00:00

Rails 3.1, Ruby 1.87 (don’t hate me). I watched the Railscasts on Nested Forms;

  • 0

Rails 3.1, Ruby 1.87 (don’t hate me). I watched the Railscasts on Nested Forms; I only put that in so you can point out where I might have missed something in the Railscasts if you know them.

Note: I added @sample_data_set.build_sample_data_template but got “unknown attribute: sample_data_set_id” on the post instead [the code is also posted with the new below).

Using a Nested form on Create/New; hit Submit and get:

ActiveRecord::UnknownAttributeError (unknown attribute:
sample_data_templates):
app/controllers/sample_data_sets_controller.rb:50:in new'
app/controllers/sample_data_sets_controller.rb:50:in
create’

Sample Data Set Model:

class SampleDataSet < ActiveRecord::Base
  has_one :sample_data_template, :dependent => :destroy
  accepts_nested_attributes_for :sample_data_template
end

Sample Data Template Model:

class SampleDataTemplate < ActiveRecord::Base
  belongs_to :sample_data_set
   #Random info generation
  def self.name_gen(*prepend)
    character_map =  [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten
    name  =  (0..8).map{ character_map[rand(character_map.length)]  }.join

    if prepend[0].nil? || prepend[0] == ""
      return name
    else
      return prepend[0].to_s + "_" + name
    end
  end

  def self.ssn_gen
    #broke this out as its own method in case someone wants some logic later one
    ssn = ""
    3.times do
      ssn = ssn + (100..999).to_a.choice.to_s
    end
    return ssn
  end

  def self.row_gen(row_count)
    @data_rows = Array.new
    i = 0
    until i > row_count do
      @row = SampleDataSet.first
      @row.officialFirstName  = SampleDataTemplate.name_gen
      @row.officialLastName   = SampleDataTemplate.name_gen
      @row.emailAddresses     = @row.officialFirstName + @row.officialLastName + "@aaa.aaa.edu"
      @row.ssn                = SampleDataTemplate.ssn_gen
      @data_rows << @row
      i += 1
    end

    return @data_rows
  end
end

Sample Data Controller#New

  def new
    @sample_data_set = SampleDataSet.new
    @sample_data_set.build_sample_data_template #after adding this I get error:unknown attribute: sample_data_set_id     
    respond_to do |format|
      format.html # new.html.erb
      format.json { render :json => @sample_data_set }
    end

Sample Data Controller#Create

  def create
    @sample_data_set = SampleDataSet.new(params[:sample_data_set])

    respond_to do |format|
      if @sample_data_set.save
        format.html { redirect_to @sample_data_set, :notice => 'Sample data set was successfully created.' }
        format.json { render :json => @sample_data_set, :status => :created, :location => @sample_data_set }
      else
        format.html { render :action => "new" }
        format.json { render :json => @sample_data_set.errors, :status => :unprocessable_entity }
      end
    end
  end
  end

Update, added form piece

  <div class="sample_fields">
    <%= f.fields_for :sample_data_templates do |builder| %>
      <%= render "sample_data", :f => builder%>
    <% end %>
  </div>

Update, Schema:

ActiveRecord::Schema.define(:version => 20120103172936) do

  create_table "sample_data_sets", :force => true do |t|
    t.string   "title"
    t.text     "description"
    t.string   "created_for"
    t.string   "created_by"
    t.integer  "number_of_records"
    t.integer  "sample_data_template_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "sample_data_templates", :force => true do |t|
    t.integer  "sample_data_set_id"
    t.string   "irn"
    t.string   "ssn"
    t.string   "officialLastName"
    t.string   "officialFirstName"
    t.string   "emailAddresses"
    t.string   "campusNum"
    t.string   "internationalId"
    t.string   "internationalIdCountry"
    t.string   "gender"
    t.string   "officialMiddleInitial"
    t.string   "previousLastName"
    t.string   "previousFirstName"
    t.string   "previousMiddleInitial"
    t.string   "addressLine1"
    t.string   "addressLine2"
    t.string   "addressLine3"
    t.string   "city"
    t.string   "state"
    t.string   "zipCode"
    t.string   "province"
    t.string   "homeAreaCode"
    t.string   "homePhoneNumber"
    t.string   "homePhoneExtenstion"
    t.string   "homePhoneCountryCode"
    t.string   "workAreaCode"
    t.string   "workPhoneNumber"
    t.string   "workExtenstion"
    t.string   "workPhoneCountryCode"
    t.string   "faxAreaCode"
    t.string   "faxPhoneNumber"
    t.string   "faxExtension"
    t.string   "faxCountryCode"
    t.string   "race"
    t.string   "previousDegree"
    t.string   "region"
    t.string   "foreignTranscript"
    t.string   "apolloEmployee"
    t.string   "nursingLicenseExpiration"
    t.string   "nursingInsuranceExpiration"
    t.string   "otherInsuranceExpiration"
    t.string   "program"
    t.string   "version"
    t.string   "groupId"
    t.string   "team"
    t.string   "enrollmentUserId"
    t.string   "admissionsUserId"
    t.string   "oldProgram"
    t.string   "oldVersion"
    t.string   "galaxyStudentOid"
    t.string   "suffixOne"
    t.string   "suffixTwo"
    t.string   "employeId"
    t.string   "promoCode"
    t.string   "revCampusOid"
    t.string   "FerpaNotes"
    t.string   "isWavierHigh"
    t.string   "executingUserId"
    t.string   "totalDeclaredExtCredits"
    t.datetime "insuranceExpireDate"
    t.datetime "acknowledgementDate"
    t.datetime "scheduledReentryDate"
    t.datetime "scheduledStartDate"
    t.datetime "dateOfBirth"
    t.datetime "enrollAgreeSignDate"
    t.boolean  "usCitizen"
    t.boolean  "financialAid"
    t.boolean  "overrideFlag"
    t.datetime "created_at"
    t.datetime "updated_at"
  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-27T23:38:28+00:00Added an answer on May 27, 2026 at 11:38 pm

    Does sample_data_templates table have a sample_data_set_id column? Perhaps you didn’t add it to the migration or did not run the migration?

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

Sidebar

Related Questions

I love Ruby and its framework, but I don't think that Ruby On Rails
I'm using Ruby on rails and I have videos that I don't want users
I don't know Ruby on Rails and I want to learn it doing something.
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
I'm just starting out with Ruby/Rails and am wondering what Rails developers use to
I'm writing a Ruby on Rails app that normally runs on Heroku or a
I'm building a web game in Ruby on Rails that relies on a choose-your-own-adventure
my Ruby On Rails unit-test fails in a simple string comparison and I can't
I am using Devise with Ruby on Rails. I have a few pages that
I am using Ruby on Rails 3.0.7 and I would like to DRY (Don't

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.