Please quote when replying.
Satsou Sa wrote in post #957750:
> Yes Marnen, I agree; it's not really useful. But I prefer to do this
> rather then having a table with only 1 row.
And you can.
> That's why I would like to
> get a singleton model with a static data (and always the same id for
> associations with other models).
Why do you need an ID? Again, please explain in more detail what you
are trying to do. has_many and belongs_to are only useful when dealing
with SQL, as I see it. Otherwise, you don't need them; a non-SQL
approach could be as simple as
class Book < ActiveModel
attr_accessor :pages
def initialize
@pages = []
end
end
book = Book.new
...and then book.pages, book.pages.count, and book.pages << Page.new all
work as expected. That's just the way OO development works.
has_many and belongs_to are a hack to make SQL databases feel more OO.
You don't need them if there's no SQL.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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/rubyonrails-talk?hl=en.