Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/controllers/videos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ def show
)
end

def create
@video = Video.new
@video.title = params[:title]
@video.overview = params[:overview]
@video.release_date = params[:release_date]
@video.image_url = params[:image_url]
@video.external_id = params[:external_id]
@video.inventory = 5
@video.save

render(
status: :ok,
json: @video.as_json(
only: [:title, :overview, :release_date, :image_url, :external_id, :inventory],
methods: [:available_inventory]
)
)

end

private

def require_video
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

resources :customers, only: [:index]

resources :videos, only: [:index, :show], param: :title
resources :videos, only: [:index, :show, :create], param: :title

post "/rentals/:title/check-out", to: "rentals#check_out", as: "check_out"
post "/rentals/:title/return", to: "rentals#check_in", as: "check_in"
Expand Down