On Feb 18, 12:27 am, Stu <[email protected]> wrote:
> On Feb 18, 3:19 pm, Stu <[email protected]> wrote:
>
>
>
> > On Feb 18, 2:03 pm, Martin Gamsjaeger <[email protected]> wrote:
>
> > > [...]
> > > What queries are looking for a model_id attribute?
>
> >    Okay -- more information on this.  I'm getting this error:
>
> > /opt/local/lib/ruby/gems/1.8/gems/dm-core-0.9.10/lib/dm-core/adapters/
> > data_objects_adapter.rb:66:in `execute_reader': ERROR:  column
> > "model_id" does not exist (PostgresError)
> > Query: SELECT "id", "document_id", "number", "part", "value", "extn",
> > "rank", "model_id" FROM "pages" WHERE ("id" = 'NSW-1833-census-01_5')
> > AND ("rank" IS NULL) ORDER BY "id", "rank" LIMIT 1
>
> >   But with the problem that the table "pages" has no "model_id"
> > attribute, but the Page resource class
> >   does inherit from one called "Model".  A complicating factor might
> > be that Model and Page are both
> >   defined in nested Ruby modules:
>
> >       module HCCDA
>
> >           module DB
>
> >               class Model...
>
> >    I suspect this is something I've misunderstood about DM though.
>
>    Forgot to add: the problem line is:
>
>       if not Page.get(id_string) ...
>
> Stu

I think I have the same problem as the OP.

class Root
  include DataMapper::Resource

  property :name, String, :key => true

  def initialize(name)
    self.name = name
  end

end

class Account < Root

  property :password, String

  def initialize(name, password)
    super(name)
    self.password = password
  end

end


What I was expecting was an accounts table created with name and
password members and probably a roots table created with a name field.
What happened was the roots table was created with the name field, no
accounts table was created and Account#save tried to save an Account
instance to the roots table (ie. tried to save both name and password
to the roots table), which obviously threw an error because roots
doesn't have a password field. Is there a way to utilize this manner
of inheritance outside of STI? What I'd like to do is flag Root as a
class that doesn't save to the database at all. I toyed w/ DM about a
year ago and I thought it had this option, but I may be confusing it
with Og.

Thanks for any help.
-Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to