Class: GalleriesController

Inherits:
InheritedResources::Base
  • Object
show all
Defined in:
app/controllers/galleries_controller.rb

Instance Method Summary collapse

Instance Method Details

#ckeditor_paramsObject



56
57
58
# File 'app/controllers/galleries_controller.rb', line 56

def ckeditor_params
  params.slice(:CKEditor, :CKEditorFuncNum, :langCode)
end

#createObject



41
42
43
# File 'app/controllers/galleries_controller.rb', line 41

def create
  create! {images_path(params.slice(:CKEditor, :CKEditorFuncNum, :langCode))}
end

#editObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/galleries_controller.rb', line 15

def edit
  edit! do |format|
    if params[:CKEditorFuncNum]
      format.html{
        render :action=>:edit, :layout=>"image_dialog"
      }
    end
  end
end

#indexObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/galleries_controller.rb', line 5

def index
  index! do |format|
    if params[:CKEditorFuncNum]
      format.html{
        render :action=>:index, :layout=>"image_dialog"
      }
    end
  end
end

#load_userObject



45
46
47
48
49
# File 'app/controllers/galleries_controller.rb', line 45

def load_user
  unless params[:user_id]
    @user ||= (current_user ? User.find(current_user.id) : super_user)
  end
end

#newObject



36
37
38
39
# File 'app/controllers/galleries_controller.rb', line 36

def new
  @gallery = Gallery.create(:user=>@user)
  new!
end

#paginated_images_for(gallery) ⇒ Object



52
53
54
# File 'app/controllers/galleries_controller.rb', line 52

def paginated_images_for(gallery)
  @images ||= Image.where(:gallery_id=>gallery.id).paginate(:page => params[:page], :order => 'created_at DESC' )
end

#showObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/galleries_controller.rb', line 25

def show
  show! do |format|
    @images = paginated_images_for(@gallery)
    if params[:CKEditorFuncNum]
      format.html{
        render :action=>:show, :layout=>"image_dialog"
      }
    end
  end
end