app/controllers/admin/galleries_controller.rb
# Define a picture like front picture to
# a gallery
# params are :
#  * id : gallery_id
#  * picture_id : the id of picture define like front
# Redirect_to edit page where the new front picture is define and see
Define a picture like front picture to
a gallery
params are :
id : gallery_id
picture_id : the id of picture define like front
Redirect_to edit page where the new front picture is define and see
Define a picture like front picture to a gallery params are : id : gallery_id picture_id : the id of picture define like front Redirect_to edit page where the new front picture is define and see
def define_front
    gallery = Gallery.find params[:id]
    picture = Picture.find params[:picture_id]
    gallery.picture_default_id = params[:picture_id]
    if gallery.save
      flash[:notice] = "You have define the picture #{picture.title} like front of gallery #{gallery.name}"
    else
      flash[:notice] = "You can't define the picture #{picture.title} like front of gallery #{gallery.name}"
    end
    params[:page] = 1 if params[:page].blank?
    redirect_to edit_admin_gallery_url(gallery, :page => params[:page])
  end
def define_front gallery = Gallery . find params [ :id ] picture = Picture . find params [ :picture_id ] gallery . picture_default_id = params [ :picture_id ] if gallery . save flash [ :notice ] = "You have define the picture #{picture.title} like front of gallery #{gallery.name}" else flash [ :notice ] = "You can't define the picture #{picture.title} like front of gallery #{gallery.name}" end params [ :page ] = 1 if params [ :page ] . blank? redirect_to edit_admin_gallery_url ( gallery , :page => params [ :page ] ) end
Define a picture like front picture to
a gallery
params are :
 id : gallery_id
 picture_id : the id of picture define like front
Redirect_to edit page where the new front picture is define and see
Define a picture like front picture to a gallery params are : id : gallery_id picture_id : the id of picture define like front Redirect_to edit page where the new front picture is define and see