Add Merb.disable :json to yoru init./rb file. AR does its own JSON
voodoo and this should get you around the issue.
-Ezra
On Oct 30, 2008, at 1:13 PM, Praveen wrote:
>
> Hi
> I downloaded 0.9.10 and merb-gen'ed a simple test app. I commented out
> DM related stuff in config files and added "dependency 'activerecord',
> '2.1.2' " to dependencies.rb. Also, replaced all DM references in
> init.rb with AR lines.
> Not that anything is wrong with DM but I need to port an existing
> application from Rails to merb and don't want to bite more than
> possible to chew. So, first rails to merb then AR to DM.
>
> One of the controllers returns json :
>
> def index
> data_model = {
> :success => true,
> :data => [
> {
> :name => 'j1'
> }
> ]
> }
> render_js data_model.to_json, :layout => false, :template => false
> end
>
> However, to_json method dies with this stacktrace. Seems like
> something to do with AR since same code works great with DM. Has
> anyone seen this issue with to_json and AR? Any ideas on how to work
> around it. thanks.
>
> ---------------------
> merb : worker (port 4000) ~ wrong number of arguments (2 for 1) -
> (ArgumentError)
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 300:in `to_json'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 300:in `json_transform'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 299:in `map'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 299:in `json_transform'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 270:in `to_json'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 284:in `json_check_circular'
> /usr/lib/ruby/gems/1.8/gems/json_pure-1.1.3/lib/json/pure/
> generator.rb:
> 270:in `to_json'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoding.rb:21:in `send'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoding.rb:21:in `encode'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoding.rb:31:in `raise_on_circular_reference'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoding.rb:20:in `encode'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoders/hash.rb:42:in `to_json'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoders/hash.rb:41:in `map'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoders/hash.rb:41:in `to_json'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> core_ext/object/misc.rb:28:in `returning'
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/
> json/encoders/hash.rb:40:in `to_json'
> /home/praveen/ruby-projects/test-app/app/controllers/jobs.rb:17:in
> `index'
> ...
>
>
> >
Ezra Zygmuntowicz
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" 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/merb?hl=en
-~----------~----~----~----~------~----~------~--~---