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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:49:59+00:00 2026-05-16T17:49:59+00:00

rails 3 newbie, using Devise for auth… I want to create the following models:

  • 0

rails 3 newbie, using Devise for auth…

I want to create the following models:

class Instance < ActiveRecord::Base
 has_many :users
 has_many :notes
end 

class User < ActiveRecord::Base
 belongs_to :instance
end

class Note < ActiveRecord::Base
 belongs_to :instance
end

To create a new note in the notes_controller.rb

def create
 @note = instance.notes.build(params[:note].merge(:instance_id => current_user.instance_id))
end

But I’m getting the following ERROR: “undefined local variable or method `instance’ for #”

Ideas?

  • 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-16T17:49:59+00:00Added an answer on May 16, 2026 at 5:49 pm

    You haven’t assigned anything to “instance” yet, so there’s nothing to reference. If you know the instance record already exists in the database, you could do something like:

    @instance = current_user.instance
    @note = Note.create(:instace_id => @instance.id)
    

    If not, you’d need to check and create it first if necessary, using the same kind of syntax.

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

Sidebar

Related Questions

I am newbie in Ruby. I installed by following this tutorial: http://udooz.net/blog/2011/02/facebook-app-using-rails-koala/ Now, when
Rails newbie here so just want to be sure I'm doing this right. I
I'm a jquery/rails newbie and I'm having trouble using .sortable(). I have expandable rows
I am a Rails Newbie. I am using fb_graph gem to extract information. Rails
I'm still a newbie with Rails (and actually development period). I'm using Rails 3.
I'm using Cancan, Devise, Rails 3 for my ordering application. Each user has many
I am a newbie developing using rails and jquery and having been searching everywhere
Apologies -- I'm a newbie using Ruby on Rails. Still a little confused about
I'm a Rails newbie, and I was initially using NetBeans + JRuby to make
I'm a newbie on Rails and Javascipt. I've been having trouble using Jquery validate

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.