Class: Wco::VideosController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Wco::VideosController
- Defined in:
- app/controllers/wco/videos_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
Alphabetized : ).
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
Alphabetized : )
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/wco/videos_controller.rb', line 8 def create @video = Wco::Video.new params[:video].permit! :create, @video if !params[:video][:thumb] @video.generate_thumbnail end if @video.save flash[:notice] = 'Success' redirect_to videos_path else flash[:alert] = 'No luck' render :action => 'new' end end |
#destroy ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/wco/videos_controller.rb', line 25 def destroy @video = Wco::Video.find params[:id] :destroy, @video flag = @video.delete if flag flash[:notice] = "deleted video" else flash[:alert] = "Cannot delete video: #{@video.errors.}" end redirect_to :action => 'index' end |
#edit ⇒ Object
37 38 39 40 |
# File 'app/controllers/wco/videos_controller.rb', line 37 def edit @video = Wco::Video.unscoped.find params[:id] :edit, @video end |
#index ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/wco/videos_controller.rb', line 42 def index :index, Wco::Video.new @videos = Wco::Video.order_by( :created_at => :desc ) if params[:q] @videos = @videos.where({ :name => /#{params[:q]}/i }) end @videos = @videos.page( params[:videos_page] ).per( 9 ) respond_to do |format| format.html format.json do render :json => @videos end end end |
#new ⇒ Object
75 76 77 78 |
# File 'app/controllers/wco/videos_controller.rb', line 75 def new @video = Wco::Video.new :new, @video end |
#show ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/controllers/wco/videos_controller.rb', line 60 def show if params[:youtube_id].present? @video = Wco::Video.unscoped.where( :youtube_id => params[:youtube_id] ).first end @video ||= Wco::Video.unscoped.find params[:id] :show, @video respond_to do |format| format.html format.json do render :json => @video end end end |
#update ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'app/controllers/wco/videos_controller.rb', line 80 def update @video = Wco::Video.unscoped.find params[:id] :update, @video # old_shared_profile_ids = @video.shared_profile_ids # if params[:video][:shared_profiles].present? # params[:video][:shared_profiles].delete('') # end # params[:video][:shared_profile_ids] = params[:video][:shared_profiles] # params[:video].delete :shared_profiles @video.update params[:video].permit! if @video.save # if params[:video][:shared_profile_ids].present? # new_shared_profiles = Ish::UserProfile.find( params[:video][:shared_profile_ids] # ).select { |p| !old_shared_profile_ids.include?( p.id ) } # ::IshManager::ApplicationMailer.shared_video( new_shared_profiles, @video ).deliver # end flash[:notice] = 'Success.' redirect_to video_path(@video) else flash[:alert] = "No luck: #{@video.errors..join(', ')}" render :edit end end |