class Object
Public Instance Methods
create()
click to toggle source
# File lib/slickr/admin/images.rb, line 67 def create create! do |format| format.html { redirect_to admin_slickr_images_path } format.json { render :json => @slickr_image.to_json( methods: [:build_for_gallery, :admin_edit_path, :admin_update_path, :admin_batch_delete_path] )} end end
destroy()
click to toggle source
# File lib/slickr/admin/pages.rb, line 56 def destroy Slickr::EventLog.create(action: :delete, eventable: resource, admin_user: current_admin_user) if resource.valid? destroy! do |format| format.html { redirect_to edit_resource_url and return if resource.valid? } format.json { render json: Slickr::Page.roots.not_draft.decorate.to_json(only: [:id, :title], methods: [:expanded, :subtitle, :edit_page_path, :add_child_path, :children, :published, :admin_delete_page_path]) } end end
edit()
click to toggle source
Calls superclass method
# File lib/slickr/admin/pages.rb, line 117 def edit super do |format| # resource.build_content_area if resource.content_areas.empty? end end
find_resource()
click to toggle source
# File lib/slickr/admin/pages.rb, line 39 def find_resource scoped_collection.friendly.find(params[:id]) end
index()
click to toggle source
# File lib/slickr/admin/images.rb, line 39 def index if params[:type] == 'page_edit' total = Slickr::Image.all.count @slickr_images = Slickr::Image.order(created_at: :desc) .limit(IMAGES_PER_PAGE) .offset((params[:page].to_i - 1)*IMAGES_PER_PAGE) respond_to do |format| format.html { render :json => { images: JSON.parse(@slickr_images.to_json(methods: [:build_for_gallery])), pagination_info: { current_page: params[:page].to_i, total_pages: ((total/IMAGES_PER_PAGE).floor + 1), images_per_page: IMAGES_PER_PAGE }, loading: true }.to_json } end elsif params[:type] == 'megadraft_pdfs' @pdfs = Slickr::Image.where('attachment like ?', '%.pdf%') index! do |format| format.html { render :json => @pdfs.to_json } end else index! end end
info_for_paper_trail()
click to toggle source
# File lib/slickr/admin/pages.rb, line 128 def info_for_paper_trail { admin_id: current_admin_user.id } if current_admin_user end
update()
click to toggle source
# File lib/slickr/admin/admin_users.rb, line 66 def update if params[:admin_user][:password].blank? && params[:admin_user][:password_confirmation].blank? params[:admin_user].delete('password') params[:admin_user].delete('password_confirmation') end update! do |format| format.html { redirect_to edit_admin_user_path(resource), notice: 'User updated' } end end
user_for_paper_trail()
click to toggle source
# File lib/slickr/admin/pages.rb, line 124 def user_for_paper_trail current_admin_user ? current_admin_user.id : 'Public user' # or whatever end