Hello

In my RoR application, I am using Couchrest_model to access a CouchDB
database.

I have a model which represents an scientific Article.
I am going to simplify my model to explain it better. An article can
have a title, a year and one or more authors.

In the couchDB database, an article can be represented like this:

article {
title = "abc",
year = "2012",
author = {
name = Paulo,
age = 34
}
}

(In the case the article only have an author)

OR

article {
title = "abc",
year = "2012",
author = {
[0] {
name = "Paulo",
age = "34"
}
[1] {
name = "Philippe",
age = "32"
}
}
}


class Article < CouchRest::Model::Base
property :title
property :year
property :author
end

In the case my article have only one author, I can access author's
information (name and age) like this:
Article.author.name
Article.author.age

But, how can I access the information of authors if the article have
more than 1 author?

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMay 21, '12 at 2:34p
activeMay 21, '12 at 2:34p
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Paulo Carvalho: 1 post

People

Translate

site design / logo © 2021 Grokbase