Add: image database table, image test site, image upload support
This commit is contained in:
parent
73d63f92e4
commit
982b72494c
13 changed files with 207 additions and 1 deletions
25
app/controllers/test/images_controller.rb
Normal file
25
app/controllers/test/images_controller.rb
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
class Test::ImagesController < ApplicationController
|
||||
def index
|
||||
@images = Image.all
|
||||
@image = Image.new
|
||||
end
|
||||
|
||||
def create
|
||||
@image = Image.new(image_params)
|
||||
|
||||
if @image.save
|
||||
respond_to do |format|
|
||||
format.turbo_stream
|
||||
format.html { redirect_to test_images_path }
|
||||
end
|
||||
else
|
||||
render :index, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def image_params
|
||||
params.require(:image).permit(:title, :file)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue