Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (81 sloc) 3.71 KB
OANotes for rails
"OANotes" as in "Orion's Apotomo Notes".
This Notes widget makes easy to add notes functionality to any rails application.
OAWidget, see:
will_paginate for notes pagination, see:
$ cd my_rails_app
$ ./script/plugins install git://
Then, you have to sync the public resources of the plugin to your app's public directory:
$ rake oa_notes:sync_resources
Since you want to manage Notes, you need to have a note model.
By default, OANotes assumes you have a "Note" model. You may create one with the following:
$ ./script/generate model Note content:text
$ rake db:migrate
If you already have a model for the notes you must specify :notes => "MyNoteClass"
About styling and javascript include:
Since the OAWidget and OANotes widgets use custom styling and javascript tools, you must include the stylesheets and javacripts in the head of your layout. To help you include the correct set of files, there are helper methods which output the list of required files:
Example of includes to add in app/views/layouts/application.html.haml:
= javascript_include_tag oa_widget_javascripts, oa_notes_javascripts
= stylesheet_link_tag oa_widget_stylesheets, oa_notes_stylesheets
====="notes", OPTIONS)
OPTIONS: A hash with following options:
:notes => string (ex: :notes => "@intervention.notes" or :notes => "MyNote")
:save => lambda {|config| config hash... }
:search => a named scope of the model used for searches, it receives self as parameter when called.
:views => [['My scope 1', :scope1], ...] an array of named scopes for view filter
:sorts => [['My filter 1', :filter1], ...] an array of named scopes for the sorting filter
:has_markings? => true or false (default: false)
:toogle_mark! => a model method name, the method is called when the user marks or unmarks a note and is passed the note as parameter
:marked? => a model method name, the method is called with note as parameter. Must return true or false
:hide => [:search, :filters, :content, :form]
:pages => [['5', 5], ['Many', 100], ...] an array of per_pages for the per_page filter
:note_partial => 'partial/path' the partial to use when rendering notes. it is passed a :note locals
:form_partial => 'partial/path' the partial to use when rendering the form. it is passed a :note locals
:title => string, this is the title to be displayed in the widget's title bar
:search_text => string, the text searched using the :search scope
:view => integer, the index of the current view scope used in the views array
:sort => integer, the index of the current sort scope used in the sorts array
:per_page => integer, the number of notes per page used in pagination
By default, all is allowed, to allow/forbid delete/create/update/mark notes you can create a Authorizations module in OANote module
Put it in app/cells/oa_notes.rb, here is an example:
module OANotes
module Authorizations
def delete?(note)
can? :delete, note
def create?(note)
can? :create, note.class
def update?(note)
can? :update, note
def toogle_mark?(note)
can? :toogle_mark, note
Checkout the wiki page for a simple tutorial:
Copyright (c) 2010 Thierry Passeron (, released under the MIT license
Something went wrong with that request. Please try again.