Added new ItemComment model

This commit is contained in:
2022-12-08 01:32:41 -05:00
parent 11d33e394b
commit 12045c684e
6 changed files with 61 additions and 1 deletions

View File

@ -1,5 +1,5 @@
class Item < Sequel::Model
one_to_many :item_comments
end

View File

@ -0,0 +1,5 @@
class ItemComment < Sequel::Model
many_to_one :items
end

View File

@ -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