I got into some weird problem. I am on rails 3.1.1 and using mongoid

Here is what I did. When I did: @line.stations.asc(:created_at).to_a
returned [#<WorkStation _id: 4ec5ecd3cf6e890e3a00001e, _type:
"WorkStation", created_at: 2011-11-18 05:27:47 UTC, updated_at:
2011-11-18 05:27:47 UTC, deleted_at: nil, index: 1, batch_size: 1,
line_id: BSON::ObjectId('4ec5ecd3cf6e890e3a00001b')>]

Its fine and now I just want it in json format with only _type field
so did @line.stations.asc(:created_at).to_a.to_json(:only => :_type)

which do works fine in development environment but when in test
environment, to_json(:only => :_type) did gave output in json format
but the filter in not working. That means it didn't had any effect of
putting :only => :_type in it. It just returns json output with the
whole fields.

I am thinking is it due to to_a method calling before to_json (which
works fine in development). Because
@line.stations.asc(:created_at).to_json(:only => :_type) does the

So the problem is filter does not works if I did
@line.stations.asc(:created_at).to_a.to_json(:only => :_type) and
works if I did @line.stations.asc(:created_at).to_json(:only
=> :_type) . And remember this happens only in test env. Both ways are
working fine in development environment.

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
Discussion Overview
grouprubyonrails-talk @
postedNov 18, '11 at 5:53a
activeNov 18, '11 at 5:53a

1 user in discussion

0v3rr!d3: 1 post



site design / logo © 2021 Grokbase