Class: Admin::GalleriesController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::GalleriesController
- Defined in:
- app/controllers/admin/galleries_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /galleries POST /galleries.xml.
-
#destroy ⇒ Object
DELETE /galleries/1 DELETE /galleries/1.xml.
-
#edit ⇒ Object
GET /galleries/#permalink/edit.
-
#follow_import ⇒ Object
See the following of mass_upload.
- #index ⇒ Object
-
#mass_upload ⇒ Object
Method to add mass upload with only one params the params define the directory where all picture are.
- #new ⇒ Object
-
#new_by_mass_upload ⇒ Object
View the form to create gallery by mass_upload.
-
#show ⇒ Object
See a gallery in Admin like a User.
-
#update ⇒ Object
PUT /galleries/1 PUT /galleries/1.xml.
Instance Method Details
#create ⇒ Object
POST /galleries POST /galleries.xml
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/admin/galleries_controller.rb', line 40 def create @gallery = Gallery.new(params[:gallery]) respond_to do |format| if @gallery.save flash[:notice] = 'Gallery was successfully created.' format.html { redirect_to(admin_galleries_url) } format.xml { render :xml => @gallery, :status => :created, :location => @gallery } else format.html { render :action => "new" } format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /galleries/1 DELETE /galleries/1.xml
74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/admin/galleries_controller.rb', line 74 def destroy @gallery = Gallery.find_by_permalink(params[:id]) @gallery.destroy flash[:notice] = "The gallery #{@gallery.name} is deleted" respond_to do |format| format.html { redirect_to(admin_galleries_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /galleries/#permalink/edit
32 33 34 35 36 |
# File 'app/controllers/admin/galleries_controller.rb', line 32 def edit @gallery = Gallery.find_by_permalink(params[:id]) raise ActiveRecord::RecordNotFound if @gallery.nil? @pictures = @gallery.pictures.paginate(:page => params[:page], :per_page => 20) end |
#follow_import ⇒ Object
See the following of mass_upload
103 104 105 106 107 108 109 |
# File 'app/controllers/admin/galleries_controller.rb', line 103 def follow_import #@imports is affect in before_filter respond_to do |format| format.html{redirect_to :action => 'index' if @imports.empty?} format.js{render :layout => false} end end |
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/admin/galleries_controller.rb', line 5 def index @galleries = Gallery.find :all, :include => 'pictures' @page_title = 'List of Gallery' end |
#mass_upload ⇒ Object
Method to add mass upload with only one params the params define the directory where all picture are
91 92 93 94 95 96 97 98 99 100 |
# File 'app/controllers/admin/galleries_controller.rb', line 91 def mass_upload if Gallery.create_from_directory params[:directory] redirect_to :action => 'follow_import' else flash[:notice] = 'the directory is not a directory' render :action => 'new' end rescue ActiveRecord::RecordInvalid render :action => 'new' end |
#new ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/admin/galleries_controller.rb', line 21 def new @gallery = Gallery.new # By default the status is online @gallery.status = true respond_to do |format| format.html # new.html.erb format.xml { render :xml => @gallery } end end |
#new_by_mass_upload ⇒ Object
View the form to create gallery by mass_upload
86 87 |
# File 'app/controllers/admin/galleries_controller.rb', line 86 def new_by_mass_upload end |
#show ⇒ Object
See a gallery in Admin like a User
11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/admin/galleries_controller.rb', line 11 def show @gallery = Gallery.find_by_permalink params[:id] unless @gallery.nil? @pictures = Picture.paginate_by_gallery_id @gallery.id, :page => params[:page], :per_page => 12 else render :status => 404 end end |
#update ⇒ Object
PUT /galleries/1 PUT /galleries/1.xml
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/admin/galleries_controller.rb', line 57 def update @gallery = Gallery.find_by_permalink(params[:id]) respond_to do |format| if @gallery.update_attributes(params[:gallery]) flash[:notice] = 'Gallery was successfully updated.' format.html { redirect_to admin_galleries_url } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity } end end end |