Guest User

Untitled

a guest
May 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. module Admin
  2. class Photos < Application
  3.  
  4. before :set_parent
  5.  
  6. def create
  7. # @photo = Photo.new(file)
  8. @photo = Photo.new
  9. @photo.file = params[:file]
  10.  
  11. if @photo.save
  12. @parent.photos << @photo
  13.  
  14. redirect resource(:admin, @parent), :message => {:notice => "Photo was successfully uploaded"}
  15. else
  16. message[:error] = "Photo failed to be uploaded"
  17. render :new
  18. end
  19. end
  20.  
  21. private
  22. def set_parent
  23. # case params[:parent]
  24. # when 'admin/shows'
  25. # @parent = Show.get(params[:id])
  26. # end
  27.  
  28. if params[:show_id]
  29. @parent = Show.get(params[:show_id])
  30. end
  31. end
  32. end
  33. end
Add Comment
Please, Sign In to add comment