Skip to content

Instantly share code, notes, and snippets.

@janxious janxious/config-routes.rb Secret
Last active Aug 29, 2015

Embed
What would you like to do?
SuperSecret::Application.routes.draw do
# ...
resources :magick_file_uploads, only: [:new, :create] do
member do
get :validate_status
end
end
# ...
end
class MagickFileUploadsController < ApplicationController
expose(:magick_files){ current_organization.magick_files }
expose(:magick_file)
expose(:magick_file_upload)
expose(:file_headers) { magick_file.magick_file_upload.file_headers }
expose(:file_headers_minus_sku) { magick_mapping.magick_file_upload.file_headers_minus_sku }
expose(:validation_data){
data = magick_file_upload.generate_validation_data(
validate_status_magick_file_magick_file_upload_url(magick_file, magick_file_upload)
)
sku_mapping_data = magick_file.generate_validation_mapping_data(
validate_mapping_status_magick_file_url(magick_file)
)
data[:details]["sku"] = sku_mapping_data[:details]["sku"]
data
}
expose(:validation_submit_path) { magick_file_path(magick_file) }
expose(:validation_back_path) { magick_files_path }
expose(:validation_forward_path) { magick_files_path }
before_filter { authorize! :manage, magick_file }
skip_filter :require_initial_catalog!
def create
magick_file_upload = magick_file.magick_file_uploads.new(params[:magick_file_upload])
magick_file_upload.magick_file = magick_file
if params[:remote_information]
magick_file.build_remote_information(params[:remote_information]).save
end
if magick_file_upload.save
if params[:reminder]
params[:reminder][:start_date] = DateTime.now+1.day
params[:reminder][:email] = current_admin_user.email
magick_file.build_reminder(params[:reminder]).save
end
redirect_to "/magick_files/#{magick_file.id}/magick_file_uploads/#{magick_file.magick_file_upload.id}/validate"
else
render :new
end
end
def validate_status
render json: magick_file_upload.allow_reupload(validation_data)
end
end
@janxious

This comment has been minimized.

Copy link
Owner Author

commented Sep 10, 2014

eyes bleeding

@janxious

This comment has been minimized.

Copy link
Owner Author

commented Sep 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.