Class: Notee::ImagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Notee::ImagesController
- Defined in:
- app/controllers/notee/images_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/notee/images_controller.rb', line 18 def create @image = Image.new @image.file = params[:image] respond_to do |format| if @image.save format.json { render json: @image, status: 200 } else format.json { render json: @image.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/notee/images_controller.rb', line 30 def destroy return unless @del_img = Image.find_by(content: params[:name]) respond_to do |format| if @del_img.destroy format.json { render json: @del_img, status: 200 } else format.json { render json: @del_img.errors, status: :internal_server_error } end end end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/notee/images_controller.rb', line 7 def index @images = Image.all.order(updated_at: :desc) render json: { status: 'success', images: @images} end |
#show ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/notee/images_controller.rb', line 12 def show @image = Image.find_by(content: params[:search_txt].to_s) if params[:search_txt] @image = Image.find_by(id: params[:search_txt].to_i) if params[:search_txt] && !@image render json: { status: 'success', image: @image} end |