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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:51:10+00:00 2026-05-31T05:51:10+00:00

I am developing 1 app in rails 3 with MongoDB (MongoMapper)in which I need

  • 0

I am developing 1 app in rails 3 with MongoDB (MongoMapper)in which I need to associate three class called user,space and address and want to fetch data accordingly but I am getting this error ,I am new to MongoMapper, Dont know how to resolve it ,plz help me !!!

   NoMethodError in Space#index

    Showing C:/Users/bacancy1/Documents/Aptana Studio 3 Workspace/Jigar/awesome_app/app/views/space/index.html.erb where line #9 raised:

    undefined method `street' for nil:NilClass

Associated Models are

1>address.rb

 class Address
    include MongoMapper::Document
    validates_presence_of :street, :city, :state, :zip, :neighborhood, :country_id
    key :street, String
    key :city, String
    key :state, String
    key :zip, String
    key :neighborhood, String
    key :country_id, String
    belongs_to :user , :class_name =>'User'
    belongs_to :space , :class_name =>'Spaces'
    end

2>space.rb

   class Space
  include MongoMapper::Document

  validates_presence_of :name, :occupancy, :additional_services, :start_time, :end_time

  key :name, String
  key :is_indoor, Boolean
  key :is_outdoor, Boolean
  key :photo, Binary
  key :summary, String
  key :occupancy, String
  key :additional_services, String
  key :start_time, String
  key :end_time, String
  key :status, Integer
  key :created_on, DateTime
  key :address_id, String
  key :user_id, String


   one :address , :class_name =>'Address'
   belongs_to :user

3>user.rb

    class User
    include MongoMapper::Document         
  #plugin MongoMapper::Devise

  validates_presence_of :firstname, :lastname, :email, :password
  validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
  validates_uniqueness_of :email
  validates_confirmation_of :password

  #key :_id, String
  key :firstname, String
  key :lastname, String
  key :email, String
  key :password, String
  key :confirm, String
  key :is_admin, Boolean

  one :address , :in => :addresses, :class_name =>'Address'
  validates_associated :addresses



  many :spaces, :in => :spaces, :class_name => 'Space'
  validates_associated :spaces

  #devise :database_authenticatable, :confirmable, :lockable, 
  #       :recoverable, :rememberable, :registerable, :trackable, 
  #       :timeoutable, :validatable, :token_authenticatable

  #attr_accessible :email, :password, :password_confirmation

end

    #devise :database_authenticatable, :confirmable, :lockable, 
  #       :recoverable, :rememberable, :registerable, :trackable, 
  #       :timeoutable, :validatable, :token_authenticatable

  #attr_accessible :email, :password, :password_confirmation

end

4> index.html.erb(view file through which I want to retrieve data)

 <!-- detail part -->
<div class="main_wrapper_box">
    <div class="sub_detail_box">
        <div class="title_box">
            <div class="title_text">
                <%= @space.name %>
            </div>
            <div class="title_sub_text">
              <h2> <%= @space.address.street %>,<%= @space.address.city %>,<%= @space.address.state %>,<%= @space.address.zip %></h2>
            </div>
        </div>
        <!-- start detail -->
        <div class="detail_box">
            <!-- 1 location -->
            <div class="comman_sub_detail_box">
                <!-- left side -->
                <div class="fea_lan_leftside">
                    <!-- start tab control -->
                    <div class="container">
                        <ul class="menu">
                            <li id="activityfeed" class="active">
                                Overview
                            </li>
                            <li id="verify">
                                Highlights
                            </li>
                            <li id="claims">
                                Map
                            </li>
                            <li id="confirm">
                                Albums
                            </li>
                        </ul>.....(continue.... )
  • 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-31T05:51:11+00:00Added an answer on May 31, 2026 at 5:51 am

    You have a typo in your address.rb:

        belongs_to :space , :class_name =>'Spaces'
    

    You don’t have a class called Spaces. You do have a class called Space. It should be:

        belongs_to :space , :class_name =>'Space'
    

    That may or may not fix your problem.

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

Sidebar

Related Questions

I am developing a rails app and I have 2 different user's role :
I am developing a Ruby on Rails app and I have a model called
I am developing an app in Rails 3 and upon signup I need the
I am developing a Rails app which should rely on existing database. There are
I'm developing a Rails 3 app on Ubuntu 10.10 and need to check the
I'm developing a Rails app that by default sets up user accounts to a
I'm developing a rails app which handles a public area (as of today, static
I'm developing a ruby on rails app and I want to be able to
I am developing a Rails app and need to automatically increment a very simple
I'm developing an master rails app which controls other rails apps. It has a

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.