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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:30:30+00:00 2026-05-28T23:30:30+00:00

I have the following 2 tables defined in migrations class CreateUsers < ActiveRecord::Migration def

  • 0

I have the following 2 tables defined in migrations

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :name
      t.string :phone
      t.string :email
      t.string :address
      t.string :resume

      t.timestamps
   end
 end
end

Class CreateResumeSections < ActiveRecordMigration
   def self.up
     create_table :resume_sections do |t|
        t.string :section_name
        t.string :html
        t.timestamps
     end
   end
 end

I have following 2 models

class User
   has_many :resume_sections, :dependent => :destroy
   attr_accessor :section_layout
   after_save :save_sections

   private
   def save_sections
     self.section_layout = ###Someother logic here that sets this variable
   end

end

class ResumeSection
   belongs_to :user
end

In my users_controller, I have the following code

class UserController < ApplicationController
   def create
      @user = User.new(params[:user])
      @user.save 
      @user.section_layout.each {|key,value|
         rs = ResumeSection.new(:section_name => key, :html => value, :user => @user)
         rs.save
       }
   end
end

In my view I have the following code

 <% @user.resume_sections.each do |section| %>
<%= section.section_name %>
<%= section.html %>
 <% end %>

I get Undefined method error for Nil:NilClass in the view. The expression @user.resume_sections is not returning to me the records that I just created and saved in the UsersController. Instead it returns nil to me. When I check the database the records are there.

Is the expression @user.resume_sections the correct expression to access these records?

Thanks
Paul

  • 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-28T23:30:30+00:00Added an answer on May 28, 2026 at 11:30 pm

    It seems to me that your you missed something in you migrations. ResumeSection needs to have and integer field called user_id. Just create a new migration that has something like this in it:

    def change
        add_column :resume_section, :user_id, :integer
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables defined declaratively (very simplified version): class Profile(Base): __tablename__ =
I have two tables defined as the following: User (ID int, name varchar) Hours
I have the following property defined: @Entity @Table(name = person) public class Person extends
I have the following tables in MySQL: team: id, name, [more stuff] person: id,
I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:
Hi have the following tables defined in my database: Transactions: - TransactionID (PK, Identity)
I have the following 2 entities: @Entity(name = Employee) @Table(name = EMPLOYEE) public class
I have the following tables: Financial : PK_FinancialID FK_SchoolID School : PK_SchoolID Class :
I have the following two tables defined... CREATE TABLE [LogLevel] ( [Id] int primary
Consider the following: I have two tables (Customers and Cases) defined as follows: **Customers**

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.