Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed message to_s method

  • Loading branch information...
commit e62046bdf514384accb1f7f40ba971c83c66a674 1 parent 0bb3363
@vivekbhagwat authored
Showing with 16 additions and 4 deletions.
  1. +16 −4 twitter.rb
View
20 twitter.rb
@@ -4,7 +4,7 @@
$global_id = 1
class Message
- attr_accessor :contents, :id, :timestamp
+ attr_accessor :contents, :id, :timestamp, :user
def initialize(str='', id=0)
@contents = str
@@ -14,8 +14,12 @@ def initialize(str='', id=0)
$global_id += 1
end
+ def to_json
+ nil.to_s
+ end
+
def to_s
- "Message: " + @contents + " at " + @timestamp
+ @contents + " posted at " + @timestamp
end
end
@@ -48,13 +52,21 @@ def to_s
get '/post/all' do
@body = '<h3>All Messages</h3>'
- messages.each do |m|
- @body += m.to_s
+ messages.each do |id, m|
+ @body += m.to_s + '<br/>'
end
erb :index
end
+get '/posts' do
+ redirect('/post/all')
+end
+
+get '/all' do
+ redirect('/post/all')
+end
+
get '/post/:id' do
id = params[:id].to_s
@body = "No such message exists"
Please sign in to comment.
Something went wrong with that request. Please try again.