Question

I want to be able to see the string like the TwitchTV name I have in my database. Here is my current code

get '/watch/:id' do |id|
  erb :mystream
  @result = Twitchtvst.all( :fields => [:Twitchtv ], 
               :conditions => { :user_id => "#{id}" }           
             )  
  puts @result              
end  

result in terminal;

#< Twitchtvst:0x007fb48b4d5a98 > 

How do I get that into a string (TwitchTV answer in database)


Opppppsss!

Here is the real code sample. Sorry!

  get '/livestream' do
    erb :livestream
    @users_streams = Twitchtvst.all   
    puts @users_streams
  end

If I add .to_s at users_stream it does not work

Was it helpful?

Solution

By adding .to_csv, not exactly a string, but it should show the content:

get '/livestream' do
    erb :livestream
    @users_streams = Twitchtvst.all   
    @users_streams.each do |us|
        p us.to_csv
    end
  end

OTHER TIPS

You're getting a Collection of Twitchtvst objects, so you need to convert each to a String:

puts Twitchtvst.all.map(&:to_s).join
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top