class CitiesController < ApplicationController has_crud_actions nested_of Country =begin before_filter :load_nested # GET /cities # GET /cities.json def index @cities = @country.cities respond_to do |format| format.html # index.html.erb format.json { render json: @cities } end end # GET /cities/1 # GET /cities/1.json def show @city = @country.cities.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @city } end end # GET /cities/new # GET /cities/new.json def new @city = @country.cities.build respond_to do |format| format.html # new.html.erb format.json { render json: @city } end end # GET /cities/1/edit def edit @city = @country.cities.find(params[:id]) end # POST /cities # POST /cities.json def create @city = @country.cities.build(params[:city]) respond_to do |format| if @city.save format.html { redirect_to [@country, @city], notice: 'City was successfully created.' } format.json { render json: @city, status: :created } else format.html { render action: "new" } format.json { render json: @city.errors, status: :unprocessable_entity } end end end # PUT /cities/1 # PUT /cities/1.json def update @city = @country.cities.find(params[:id]) respond_to do |format| if @city.update_attributes(params[:city]) format.html { redirect_to [@country, @city], notice: 'City was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @city.errors, status: :unprocessable_entity } end end end # DELETE /cities/1 # DELETE /cities/1.json def destroy @city = @country.cities.find(params[:id]) @city.destroy respond_to do |format| format.html { redirect_to country_cities_url(@country) } format.json { head :no_content } end end private def load_nested @country = Country.find(params[:country_id]) end =end end