Added new ItemComment model
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
class Item < Sequel::Model
|
||||
|
||||
|
||||
one_to_many :item_comments
|
||||
|
||||
end
|
||||
|
5
lib/models/item_comment.rb
Normal file
5
lib/models/item_comment.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ItemComment < Sequel::Model
|
||||
|
||||
many_to_one :items
|
||||
|
||||
end
|
@ -44,3 +44,12 @@ get '/item/:item_id' do
|
||||
:item => item
|
||||
}
|
||||
end
|
||||
|
||||
post '/item/:item_id/comment' do
|
||||
item = Item.first(id: params[:item_id])
|
||||
|
||||
comment = ItemComment.create(body: params[:comment_body])
|
||||
item.add_item_comment(comment)
|
||||
|
||||
redirect "/item/#{item.id}"
|
||||
end
|
||||
|
Reference in New Issue
Block a user