Class: Admin::VideosController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- Admin::VideosController
- Defined in:
- app/controllers/admin/videos_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Methods included from BaseHelper
Instance Method Details
#create ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/admin/videos_controller.rb', line 25 def create @video = Video.new(params[:video]) if @video.save redirect_to admin_videos_path else render :new end end |
#destroy ⇒ Object
49 50 51 52 53 |
# File 'app/controllers/admin/videos_controller.rb', line 49 def destroy @video = Video.find(params[:id]) @video.destroy redirect_to admin_videos_path end |
#edit ⇒ Object
34 35 36 37 38 |
# File 'app/controllers/admin/videos_controller.rb', line 34 def edit @video = Video.find(params[:id]) n = 3 - @video.sources.size n.times { @video.sources.build } end |
#index ⇒ Object
11 12 13 14 |
# File 'app/controllers/admin/videos_controller.rb', line 11 def index @search = Video.search(params[:search]) @videos = @search.order(:title).page(params[:page]) end |
#new ⇒ Object
20 21 22 23 |
# File 'app/controllers/admin/videos_controller.rb', line 20 def new @video = Video.new 3.times { @video.sources.build } end |
#show ⇒ Object
16 17 18 |
# File 'app/controllers/admin/videos_controller.rb', line 16 def show @video = Video.find(params[:id]) end |
#update ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/controllers/admin/videos_controller.rb', line 40 def update @video = Video.find(params[:id]) if @video.update_attributes(params[:video]) redirect_to admin_videos_path else render :edit end end |