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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:44:45+00:00 2026-05-14T04:44:45+00:00

I am developing a Rails 1.0 application (I can’t upgrade, it’s a strange situation)

  • 0

I am developing a Rails 1.0 application (I can’t upgrade, it’s a strange situation) for which I am trying to use the :composed_of functionality. I have a class called StreetAddress:

class StreetAddress
  attr_reader :address, :address2, :city, :state_id, :zip_code

  def initialize(address, address2, city, state_id, zip_code)
    @address = address
    @address2 = address2
    @city = city
    @state_id = state_id
    @zip_code = zip_code
  end


end 

and a model class called Hotel

class Hotel < ActiveRecord::Base
  composed_of :street_address
  # ...

end

which has columns:

"id", "brand_id", "code", "location_name", "address", "address2", "city", "state_id", "zip_code", "phone_number", "phone_ext", "fax_number", "time_zone", "url", "room_service_email", "manager_name", "manager_email"

However when I try to access the aggregation I get an error:

>> h = Hotel.find(1)
=> #<Hotel:0x38ad718 @attributes={"fax_number"=>"1-623-420-0124", "city"=>"Twin
Falls", "address2"=>"285", "brand_id"=>"1", "code"=>"XZWUXUSZ", "manager_email"=
>"molestie.tellus.Aenean@erosnec.ca", "url"=>"http://www.xycdkzolukfvu.hom", "ph
one_number"=>"1-805-706-9995", "zip_code"=>"72436", "phone_ext"=>"48060", "id"=>
"1", "manager_name"=>"Igor Mcdowell", "room_service_email"=>"Duis.risus@Donecvit
ae.ca", "time_zone"=>"America/Boise", "state_id"=>"15", "address"=>"P.O. Box 457
, 7405 Dignissim Avenue", "location_name"=>"penatibus et magnis"}>
>> h.street_address
ArgumentError: wrong number of arguments (1 for 5)
    from (eval):3:in `initialize'
    from (eval):3:in `new'
    from (eval):3:in `street_address'
    from (irb):6

Why?

  • 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-14T04:44:46+00:00Added an answer on May 14, 2026 at 4:44 am

    composed_of will attempt to call the constructor of the object with the fields it knows about. In your case, it is only sending the street_address attribute (which doesn’t seem to exist, so will probably be nil). Make sure to declare your composed_of with the mapping attribute set so that it will send all the attributes.

    composed_of :street_address, :mapping => [%w(address address), %w(address2 address2), %w(city city), %w(state_id state_id), %w(zip_code zip_code)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby on Rails application that I'm developing on my computer, which
I am developing a rails application in which I have two models User and
I am developing a Rails application and would like to understand when to use
I'm developing a new rails application which is supposed to be installed several times
In the Rails application I’m currently developing I have many request models. We are
I have a Rails application that accepts file uploads of CSV files. When developing
I have been developing a sample application after reading Rails 3 Tutorial book. In
I am developing a Rails application which will need frequent access to public APIs,
I'm developing the Order Model for a Rails application.I'm trying to represent an Order
I am developing a Ruby on Rails application with multilingual support. Now I have

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.