Guest User

Untitled

a guest
May 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. # in model/tweet
  2.  
  3. def add_a_tweet_on_timeline_to(username)
  4. add_a_tweet_on_the_file("#{RAILS_ROOT}/public/#{username}.js")
  5. end
  6.  
  7. def add_a_tweet_on_the_file(file)
  8. File.open(file, 'r+') {|io|
  9. finale = "]);\n"
  10. io.seek(-finale.size, IO::SEEK_END)
  11. io.puts %|,{user: "#{@owner.username}", text: "#{@text}"}|
  12. io.write finale
  13. }
  14. end
Add Comment
Please, Sign In to add comment