Sha256: 6043b4162bc87c71c0047e3e54e26cc3004a21f3e441b54e59b1ea9f4addf741

Contents?: true

Size: 1.25 KB

Versions: 28

Compression:

Stored size: 1.25 KB

Contents

 class NotesController < ArtfullyOseController
  before_filter :find_person

  def new
    @note = Note.new
    @note.occurred_at = DateTime.now.in_time_zone(current_user.current_organization.time_zone)
    render :layout => false
  end

  def create
    note = @person.notes.build(params[:note])
    note.user = current_user
    note.organization = current_user.current_organization
    note.save
    redirect_to @person
  end

  def destroy
    if Note.exists? params[:id]
      Note.destroy(params[:id])
      flash[:notice] = "Your note has been deleted."
    else
      flash[:notice] = "We couldn't find that note to delete."
    end
    redirect_to person_url(@person)
  end

  def edit
    @note = Note.find(params[:id])
    render :layout => false
  end

  def update
    @note = Note.find params[:id]

    if @note.update_attributes(params[:note])
      flash[:notice] = "Note updated successfully!"
      redirect_to person_url(@person)
    else
      flash[:alert] = "There was a problem editing your note, please contact support if the problem persists."
      redirect_to :back
    end
  end

  private

  def find_person
    id = params[:person_id] || params[:individual_id] || params[:company_id]
    @person = Person.find(id)
    authorize! :edit, @person
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/controllers/notes_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/notes_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/notes_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.23 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.21 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.15 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.12 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.11 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.10 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.9 app/controllers/notes_controller.rb
artfully_ose-1.2.0.pre.8 app/controllers/notes_controller.rb