ruby on rails - '.each do' is leaving some line like "#<Table:0x224af70>" -


i'm trying prepare json object rails app. here code:

#videos_controller   def show      @video = video.find(:all,                          :conditions => { :published => true, :trash => false },                            :order => 'random()', :limit => 1)       respond_to |format|       format.html # show.html.erb       format.json {render :partial => "videos/show.json"}     end   end   #_show.json <%= @video.each |video| %> {     "video_link": "<%= video.link %>",     "video_id": "http://website.com/videos/each/<%=video.id%>" } <% end %> 

but @ videos/show.json i'm getting that

{   "video_link": "http://www.youtube.com/watch?v=6rmwnwtps6i",   "video_id": "http://website.com/videos/each/51" } #<video:0x220a060> 

how avoid nasty last line , getting from? think, becouse of that, doesn't allow me work json object properly. know, answer pretty simple, can't it. thank in advance.

take out equal sign in line <%= @video.each |video| %> it's <% @video.each |video| %>. segment you're seeing default to_s method being returned each method.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -