Class: GroupsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- GroupsController
- Defined in:
- app/controllers/groups_controller.rb
Instance Method Summary collapse
- #check_logo ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #findgroup ⇒ Object
- #get_logo ⇒ Object
- #handle_logo(logo) ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#check_logo ⇒ Object
51 52 53 54 |
# File 'app/controllers/groups_controller.rb', line 51 def check_logo logo=params[:group][:logo] params[:group][:logo] = logo.blank? ? nil : handle_logo(logo) end |
#create ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'app/controllers/groups_controller.rb', line 56 def create @group=Group.new(params[:group]) if @group.save flash[:notice]="群组创建成功" else flash[:error]="群组创建失败" end redirect_to :back and return end |
#destroy ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/groups_controller.rb', line 78 def destroy #if @group.delete params[:group][:enable]=false if @group.update_attributes(params[:group]) flash[:notice]="群组删除成功" else flash[:error]="群组删除失败" end redirect_to :back and return end |
#edit ⇒ Object
21 22 |
# File 'app/controllers/groups_controller.rb', line 21 def edit end |
#findgroup ⇒ Object
7 8 9 |
# File 'app/controllers/groups_controller.rb', line 7 def findgroup @group=Group.find(params[:id]) end |
#get_logo ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/groups_controller.rb', line 27 def get_logo id=@group.logo["grid_id"] if FileGrid.exist?(id) f=FileGrid.get(id) send_data(f.read,:type=>f.content_type) #response.headers['Content-Type'] = f.content_type else render :text=>"文件不存在" end end |
#handle_logo(logo) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/groups_controller.rb', line 38 def handle_logo(logo) filehash={} Zbox::QmExt.resize(logo.tempfile.path,:size=>:tinylogo) file_id=FileGrid.put(File.open(logo.tempfile.path),:filename=>logo.original_filename) thefile=FileGrid.get(file_id) filehash["grid_id"]=file_id filehash["content_type"]=logo.content_type filehash["chunk_size"]=thefile.chunk_size filehash["filename"]=thefile.filename return filehash end |
#index ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/groups_controller.rb', line 11 def index @page,@per_page=params[:page],5 @minum = @page ? @per_page*(@page.to_i-1) : 0 @groups=Group.paginate :pages=>@page,:per_page=>@per_page end |
#new ⇒ Object
17 18 19 |
# File 'app/controllers/groups_controller.rb', line 17 def new @group=Group.new end |
#show ⇒ Object
24 25 |
# File 'app/controllers/groups_controller.rb', line 24 def show end |
#update ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/groups_controller.rb', line 67 def update logo=params[:group][:logo] params[:group][:logo]=File.read(logo.tempfile.path) if @group.update_attributes(params[:group]) flash[:notice]="群组更新成功" else flash[:error]="群组更新失败" end redirect_to :back and return end |