One-to-Many Relation

I don't know if the relation between property and owner working or not , when I tried a query I got this error:

Loading development environment (Rails 3.2.13)
irb(main):001:0> Owner.find(1).properties
  Owner Load (18.1ms)  SELECT "owners".* FROM "owners" WHERE "owners"."id" = ? LIMIT 1  [["id", 1]]
  Property Load (0.1ms)  SELECT "properties".* FROM "properties" WHERE "properties"."owner_id" = 1
ActiveRecord::SubclassNotFound: The single-table inheritance mechanism failed to locate the subclass: 'House'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Property.inheritance_column to use another column for that information.
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/inheritance.rb:143:in `rescue in find_sti_class'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/inheritance.rb:136:in `find_sti_class'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/inheritance.rb:62:in `instantiate'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/querying.rb:38:in `block (2 levels) in find_by_sql'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/querying.rb:38:in `collect!'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/querying.rb:38:in `block in find_by_sql'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/explain.rb:41:in `logging_query_plan'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/querying.rb:37:in `find_by_sql'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/relation.rb:171:in `exec_queries'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/relation.rb:160:in `block in to_a'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/explain.rb:34:in `logging_query_plan'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/relation.rb:159:in `to_a'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:159:in `all'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/associations/collection_association.rb:382:in `find_target'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/associations/collection_association.rb:335:in `load_target'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/associations/collection_proxy.rb:44:in `load_target'
    from /var/lib/gems/1.9.2/gems/activerecord-3.2.13/lib/active_record/associations/collection_proxy.rb:87:in `method_missing'
    from /var/lib/gems/1.9.2/gems/railties-3.2.13/lib/rails/commands/console.rb:47:in `start'
    from /var/lib/gems/1.9.2/gems/railties-3.2.13/lib/rails/commands/console.rb:8:in `start'
    from /var/lib/gems/1.9.2/gems/railties-3.2.13/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'

my property.rb file:

class Property < ActiveRecord::Base
  attr_accessible :owner_id, :p_city, :p_street, :postcode, :rent, :rooms, :type
  belongs_to :owner
  has_one :ticket
end

my owner.rb file:

class Owner < ActiveRecord::Base
  attr_accessible :address, :f_name, :l_name, :tel_no
  has_many :properties
end

Answers


You can't use "type" as an attribute/column because it is reserved for inheritance stuff. You should change both your model's attribute and the db column to something else.


Need Your Help

How can I position my navigation bar further up on the page?

html css

So I'm playing around with my sprite based navigation menu for my school website project, but I can't seem to figure how I can move my navigation bar so it moves up without dragging the content alo...

Appending text from first line to last of a file through loop

bash shell

I want to append a text to the end of the each line of a existing file. This text has to be appended from the first line of the file to last line.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.