Class: IshManager::VideosController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::VideosController
- Defined in:
- app/controllers/ish_manager/videos_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
alphabetized : ).
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
alphabetized : )
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 8 def create @video = Video.new params[:video].permit(%i| name descr is_public is_trash is_feature x y lang youtube_id site user_profile premium_tier premium_purchases thumb video |) @video.user_profile = @current_profile :create, @video if @video.save flash[:notice] = 'Success' redirect_to videos_path else flash[:alert] = 'No luck' render :action => 'new' end end |
#destroy ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 23 def destroy @video = Video.unscoped.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
35 36 37 38 39 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 35 def edit @video = Video.unscoped.find params[:id] @user_profiles_list = Ish::UserProfile.list :edit, @video end |
#index ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 41 def index :index, Video.new @videos = Video.unscoped.where( is_trash: false, :user_profile => @current_profile ).order_by( :created_at => :desc ) if params[:q] @videos = @videos.where({ :name => /#{params[:q]}/i }) end @videos = @videos.page( params[:videos_page] ).per( 10 ) respond_to do |format| format.html do render end format.json do render :json => @videos end end end |
#new ⇒ Object
74 75 76 77 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 74 def new @video = Video.new :new, @video end |
#show ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 61 def show @video = Video.unscoped.where( :youtube_id => params[:youtube_id] ).first if params[:youtube_id].present? @video ||= Video.unscoped.find params[:id] :show, @video respond_to do |format| format.html format.json do render :json => @video end end end |
#update ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/ish_manager/videos_controller.rb', line 79 def update @video = Video.unscoped.find params[:id] :update, @video @video.update params[:video].permit! if @video.save flash[:notice] = 'Success.' redirect_to videos_path else flash[:alert] = "No luck: #{@video.errors.}" render :edit end end |