Class: MoviesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/movies_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/movies_controller.rb', line 19

def create
  @movie = Movie.new(movie_params)

  respond_to do |format|
    if @movie.save
      format.html { redirect_to @movie, notice: 'Movie was successfully created.' }
      format.json { render :show, status: :created, location: @movie }
    else
      format.html { render :new }
      format.json { render json: @movie.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject


45
46
47
48
49
50
51
# File 'app/controllers/movies_controller.rb', line 45

def destroy
  @movie.destroy
  respond_to do |format|
    format.html { redirect_to movies_url, notice: 'Movie was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#editObject


16
17
# File 'app/controllers/movies_controller.rb', line 16

def edit
end

#indexObject


4
5
6
# File 'app/controllers/movies_controller.rb', line 4

def index
  @movies = Movie.all
end

#newObject


12
13
14
# File 'app/controllers/movies_controller.rb', line 12

def new
  @movie = Movie.new
end

#showObject


8
9
10
# File 'app/controllers/movies_controller.rb', line 8

def show
  render @movie if request.xhr?
end

#updateObject


33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/movies_controller.rb', line 33

def update
  respond_to do |format|
    if @movie.update(movie_params)
      format.html { redirect_to @movie, notice: 'Movie was successfully updated.' }
      format.json { render :show, status: :ok, location: @movie }
    else
      format.html { render :edit }
      format.json { render json: @movie.errors, status: :unprocessable_entity }
    end
  end
end