Class: PhotosController

Inherits:
ApplicationController show all
Defined in:
app/controllers/photos_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#fresh_when, #redirect_back_or_default, #redirect_referrer_or_default, #render_403, #render_404, #render_optional_error_file, #require_user, #set_active_menu, #set_locale, #set_seo_meta, #store_location, #unread_notify_count

Instance Method Details

#createObject


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/photos_controller.rb', line 4

def create
  # 浮动窗口上传
  @photo = Photo.new
  @photo.image = params[:file]
  if @photo.image.blank?
    render json: { ok: false }, status: 400 and return
  end

  @photo.user_id = current_user.id
  if @photo.save
    render json: { ok: true, url: @photo.image.url }
  else
    render json: { ok: false }
  end
end