Class: NotesController
- Inherits:
-
AuthorizedController
- Object
- InheritedResources::Base
- AuthorizedController
- NotesController
- Defined in:
- app/controllers/notes_controller.rb
Instance Method Summary collapse
Methods inherited from AuthorizedController
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/notes_controller.rb', line 17 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 |
#find_note_of_sth ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/controllers/notes_controller.rb', line 26 def find_note_of_sth params.each do |name, value| if name =~ /(.+)_id$/ return $1.classify.constantize.find(value) end end nil end |
#index ⇒ Object
4 5 6 7 8 9 |
# File 'app/controllers/notes_controller.rb', line 4 def index @note_of_sth = find_note_of_sth @notes = @note_of_sth.notes.paginate(:page => params[:page]) index! end |
#new ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/notes_controller.rb', line 11 def new @note = Note.new(:note_of_sth => parent, :user => current_user) new! end |