Class: Refinery::Admin::ImagesController
- Inherits:
-
Refinery::AdminController
- Object
- Refinery::AdminController
- Refinery::Admin::ImagesController
- Defined in:
- app/controllers/refinery/admin/images_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#insert ⇒ Object
This renders the image insert dialog.
- #new ⇒ Object
Instance Method Details
#create ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'app/controllers/refinery/admin/images_controller.rb', line 40 def create @images = [] begin unless params[:image].present? and params[:image][:image].is_a?(Array) @images << (@image = ::Refinery::Image.create(params[:image])) else params[:image][:image].each do |image| @images << (@image = ::Refinery::Image.create(:image => image)) end end rescue Dragonfly::FunctionManager::UnableToHandle logger.warn($!.) @image = ::Refinery::Image.new end unless params[:insert] if @images.all?(&:valid?) flash.notice = t('created', :scope => 'refinery.crudify', :what => "'#{@images.map(&:title).join("', '")}'") if from_dialog? @dialog_successful = true render :nothing => true, :layout => true else redirect_to refinery.admin_images_path end else self.new # important for dialogs render :action => 'new' end else # if all uploaded images are ok redirect page back to dialog, else show current page with error if @images.all?(&:valid?) @image_id = @image.id if @image.persisted? @image = nil self.insert end end end |
#insert ⇒ Object
This renders the image insert dialog
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/refinery/admin/images_controller.rb', line 19 def insert self.new if @image.nil? @url_override = refinery.admin_images_path(request.query_parameters.merge(:insert => true)) if params[:conditions].present? extra_condition = params[:conditions].split(',') extra_condition[1] = true if extra_condition[1] == "true" extra_condition[1] = false if extra_condition[1] == "false" extra_condition[1] = nil if extra_condition[1] == "nil" end find_all_images(({extra_condition[0].to_sym => extra_condition[1]} if extra_condition.present?)) search_all_images if searching? paginate_images render :action => "insert" end |