Commit 4dd9f665073c10bde64e36fa3301460bb63429d6
1 parent
46998fbb
Exists in
master
and in
25 other branches
Adds wrap_parameters initializer
As of Rails 3, include_root_in_json is true by default, which causes the json generated for rails models to be in the format: `{ profile => { name => 'ze', ... } }` instead of: `{ name => 'ze', ... }` This was breaking some javascript for the sniffer plugin and possibly other places. This initializer is part of the template for rails 3 applications and set include_root_in_json to false. The default configuration for rails 3 applications also enables parameters wrapping for json, however I disabled this feature by setting wrap parameter format to an empty array, as suggested by the documentation, since we are not using this on noosfero.
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,13 @@ |
1 | +# Be sure to restart your server when you modify this file. | |
2 | +# This file contains settings for ActionController::ParamsWrapper which | |
3 | +# is enabled by default. | |
4 | + | |
5 | +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. | |
6 | +ActiveSupport.on_load(:action_controller) do | |
7 | + wrap_parameters :format => [] | |
8 | +end | |
9 | + | |
10 | +# Disable root element in JSON by default. | |
11 | +ActiveSupport.on_load(:active_record) do | |
12 | + self.include_root_in_json = false | |
13 | +end | ... | ... |