This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update | |
respond_to do |format| | |
if @photo_gallery.update(photo_gallery_params) | |
# add compare method in here | |
compare_photos(params[:photos]) | |
format.html { redirect_to @photo_gallery, notice: 'Photo gallery was successfully updated.' } | |
format.json { render :show, status: :ok, location: @photo_gallery } | |
else | |
format.html { render :edit } | |
format.json { render json: @photo_gallery.errors, status: :unprocessable_entity } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@photo_gallery = PhotoGallery.new(photo_gallery_params) | |
respond_to do |format| | |
if @photo_gallery.save | |
# add save photos method in here | |
save_photos(params[:photos]) | |
format.html { redirect_to @photo_gallery, notice: 'Photo gallery was successfully created.' } | |
format.json { render :show, status: :created, location: @photo_gallery } | |
else | |
format.html { render :new } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_photo_gallery | |
@photo_gallery = PhotoGallery.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def photo_gallery_params | |
# add :photos param below | |
params.require(:photo_gallery).permit(:description,:photos) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Photo < ActiveRecord::Base | |
belongs_to :photo_gallery | |
has_attached_file :image, :styles => { | |
:medium => "300x300>", | |
:thumb => "100x100>" | |
}, | |
:path => ":rails_root/app/assets/images/photos/:style/:filename" | |
validates_attachment_content_type :image, :content_type => /\Aimage\/.*\Z/ | |
end |
NewerOlder