Created
November 20, 2011 00:15
-
-
Save jagmitg/1379585 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FilmsController < ApplicationController | |
# GET /films | |
# GET /films.json | |
def index | |
@cinema = Cinema.find(:cinema_id) | |
@films = @cinema.films | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @films } | |
end | |
end | |
# GET /films/1 | |
# GET /films/1.json | |
def show | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.find(params[:id]) | |
respond_to do |format| | |
format.html # show.html.erb | |
format.json { render json: @film } | |
end | |
end | |
# GET /films/new | |
# GET /films/new.json | |
def new | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.new | |
respond_to do |format| | |
format.html # new.html.erb | |
format.json { render json: @film } | |
end | |
end | |
# GET /films/1/edit | |
def edit | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.find(params[:id]) | |
end | |
# POST /films | |
# POST /films.json | |
def create | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.new(params[:id]) | |
respond_to do |format| | |
if @film.save | |
format.html { redirect_to @film, notice: 'Film was successfully created.' } | |
format.json { render json: @film, status: :created, location: @film } | |
else | |
format.html { render action: "new" } | |
format.json { render json: @film.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# PUT /films/1 | |
# PUT /films/1.json | |
def update | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.find(params[:id]) | |
respond_to do |format| | |
if @film.update_attributes(params[:film]) | |
format.html { redirect_to @film, notice: 'Film was successfully updated.' } | |
format.json { head :ok } | |
else | |
format.html { render action: "edit" } | |
format.json { render json: @film.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /films/1 | |
# DELETE /films/1.json | |
def destroy | |
@cinemas = Cinema.find(params[:cinema_id]) | |
@film = Film.find(params[:id]) | |
@film.destroy | |
respond_to do |format| | |
format.html { redirect_to films_url } | |
format.json { head :ok } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment