Sha256: d56061ee3f9537259a559d56e9dce13a5d58290adb9df0bc2687ee4a73b59bba

Contents?: true

Size: 711 Bytes

Versions: 1

Compression:

Stored size: 711 Bytes

Contents

class NotesController < AuthorizedController
  belongs_to :employee, :polymorphic => true

  def index
    @note_of_sth = find_note_of_sth
    @notes = @note_of_sth.notes.paginate(:page => params[:page])

    index!
  end

  def new
    @note = Note.new(:note_of_sth => parent, :user => current_user)

    new!
  end

  def create
    @note_of_sth = find_note_of_sth
    @note = @note_of_sth.notes.build(params[:note])

    create! do |format|
      format.html { redirect_to eval("#{parent_type}_notes_path(@note_of_sth)") }
    end
  end

  def find_note_of_sth
    params.each do |name, value|
      if name =~ /(.+)_id$/
        return $1.classify.constantize.find(value)
      end
    end
    nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bookyt-0.0.1 app/controllers/notes_controller.rb