ruby on rails - How to select only one element of associated objects in to_json / to_xml -


I have the following problem my app (a prototype of the API) should be able to respond to the ultimate (like language). I am already able to respond to the request by sending an entierly object (with related items) as a JSON but now I want to select related items by parameter. My code:

  object.to_json (include => gt; {: texts_in_diff_languages ​​= & gt; {#here I only given params [: language] Should be able to select)}}  

Do you have any ideas? Thanks!

OK, I try to explain it in another way: I have three tables, texts and third languages ​​are called books and there is one language in a text. BooksC OntoRoller, I want to write a method which only gives a book to JSON: title, book: text: content of a specific language This language I want to get from a parameter (parameter [: language_id]). Do you understand it now?

My code: (Selects a book and is included in all the texts of all languages)

  Render: Jason => To_json (: = => [: title],: include = & gt; {: texts = & gt; {: include = & gt; {: languages}}})  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -