[Rails] how to remove changed_attributes from yaml response
Hi,
I am using attr_accessor attributes in model class and assigning the
values to attr_accessor dynamically in controller. And am sending the
data object to display in Yaml format. I am getting the response along
with changed_attributes but I don't want changed_attributes details in
my response.
build Model code
class Test < ActiveRecord::Base
attr_accessor: t_1, t_2, t_3, t_4
end
In Test Controller code:
#build is controller object
tb = ["[5, 30.14]","[0, 12.0]","[1, 11.0]","[2, 11.0]"]
$i=1
while $i <= tb.length do
$tbVal = "t_#{$i}"
build["#{$tbVal}"] = tb[$i-1]
$i += 1
wants.yaml { render :text => tb.to_yaml, :content_type =>
"application/x-yaml", :layout => layout}
Ouput:
--- ! ruby/object:Test
attributes:
build_1: "[5, 30.14]"
build_2: "[0, 12.0]"
build_3: "[1, 11.0]"
build_4: "[2, 11.0]"
attribute_cache: {}
changed_attributes:
build_1:
build_2:
build_3:
build_4:
I am getting the output with "changed_attributes" with empty values and
I don't want to display the changed_attributes in Yaml.
Could anyone please help me to remove the changed_attributes data from
yaml response?
Thanks
Madan
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home