Class Admin::BaseController
In: app/controllers/admin/base_controller.rb
Parent: ApplicationController

Methods

Public Instance methods

[Source]

    # File app/controllers/admin/base_controller.rb, line 26
26:   def paginate
27:     name = params[:controller].gsub(/.*\//,'')
28:     name = 'items' if name == 'analytics'
29:     # raise name.inspect
30:     objs = (name.singularize.capitalize.constantize).page_find(params[:page])
31:     render :update do |page|
32:       page[name].html render(:partial => name.singularize, :collection => objs)
33:       page[:paginate].html will_paginate(objs, :id => :paginate)
34:     end
35:   end

[Source]

    # File app/controllers/admin/base_controller.rb, line 6
 6:   def resolve_flag
 7:     flag = Flag.find(params[:id])
 8:     flag.update_attribute(:active, false)
 9:     obj = params[:item_id] ? Item.find(params[:item_id]) : Comment.find(params[:comment_id])
10: 
11:     render :update do |page|
12:       page["#{obj.class.to_s.downcase}_flag_count_#{obj.id}"].html obj.flags.count_active
13:       page["#{obj.class.to_s.downcase}_#{obj.id}_flag_#{flag.id}"].html render(:partial => 'admin/shared/flag', :locals => { :flag => flag, :obj => obj, :type => obj.class.to_s.downcase})
14:     end
15:   end

[Source]

    # File app/controllers/admin/base_controller.rb, line 17
17:   def state
18:     klass = (params[:controller] =~ /items/) ? Item : Comment
19:     obj = klass.find(params[:id], :include => :flags)
20:     obj.send(params[:state])
21:     render :update do |page|
22:       page["#{klass.to_s.downcase}_#{obj.id}"].replace render(:partial => klass.to_s.downcase, :locals => { :item => obj, :comment => obj })
23:     end
24:   end

[Source]

    # File app/controllers/admin/base_controller.rb, line 37
37:   def update_translations(params, record, type)
38:     translations.values.each do |locale|
39:       if value = params.delete(locale).values.first
40:         if translation = record.translations.find_by_locale(locale)
41:           translation.update_attribute(:value, value)
42:         else
43:           translation = Translation.create(:content_id => record.id, :content_type => type, :value => value, :locale => locale)
44:         end
45:       end
46:     end
47:   end

[Validate]