# Rails 3: including a json object in views

**URL:** <https://www.ruby-forum.com/t/rails-3-including-a-json-object-in-views/185524>\
**Category:** Rails\
**Created:** [March 22, 2010, 9:32am UTC](https://www.ruby-forum.com/t/rails-3-including-a-json-object-in-views/185524 "2010-03-22T09:32:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Gerstenblat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@Michael\_Gerstenblat](https://www.ruby-forum.com/u/Michael_Gerstenblat)\
**Post date:** [March 22, 2010, 9:32am UTC](https://www.ruby-forum.com/t/rails-3-including-a-json-object-in-views/185524/1 "2010-03-22T09:32:30Z")

</div>

Hi All,  
I’m trying to embed a json object into one of views, and what used to  
work  
in Rails 2.x now no longer works.

I’m generating the json code in my Staff model:  
def schedule  
appointments = Appointment.find(:all, :conditions =\> {:staff\_id =\>  
self.id})  
appointments.to\_json(  
:only =\>  
[:id,:start,:end,:title,:body,:repeat,:repeat\_id,:mon\_repeat,:tue\_repeat,:wed\_repeat,:thu\_repeat,:fri\_repeat,:sat\_repeat,:sun\_repeat])  
end

In my view I’m doing the following:

Finally, the output is not in JSON format, but rather:

Does anyone know what I can do so that the JSON object is rendered so  
that  
my javascript can read it?

Thanks.
