Sha256: 54d96d475715391f85b66480f69039ec97adf0a99f9a773ed2e7bf38c08de8b0

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

class JournalsController < ApplicationController
  before_filter :get_calendar
  respond_to :json, :html

  def index
    respond_with(@calendar, (@journals = @calendar.journals.all))
  end

  def show
    respond_with(@calendar, (@journal = @calendar.journals.find(params[:id])))
  end

  def new
    respond_with(@calendar, (@journal = @calendar.journals.new))
  end

  def edit
    respond_with(@calendar, (@journal = @calendar.journals.find(params[:id])))
  end

  def create
    @journal = @calendar.journals.create(params[:journal])
    flash[:notice] = "Journal successfully created" if @journal.save
    respond_with(@calendar, @journal)
  end

  def update
    @journal = @calendar.journals.find(params[:id])
    @journal.update_attributes(params[:calendar])
    respond_with(@calendar, @journal)
  end

  def destroy
    @journal = @calendar.journals.find(params[:id])
    @journal.destroy

    respond_to do |format|
      format.html { redirect_to(calendars_journals_url(@calendar, @journal)) }
      format.xml  { head :ok }
    end
  end

  private
    def get_calendar
      @calendar = Calendar.find(params[:calendar_id]) unless params[:calendar_id].nil?
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
actic-0.0.5.1 lib/app/controllers/journals_controller.rb
actic-0.0.5 lib/app/controllers/journals_controller.rb