Class: ActiveMetadata::NotesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/active_metadata/notes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
# File 'app/controllers/active_metadata/notes_controller.rb', line 23

def create
  @document = params[:model_name].to_class.find(params[:model_id])
  @document.create_note_for(params[:field_name], params[:note], params[:starred], params[:group])
  respond_to do |format|
    # TODO redirect to edit
    format.js       
  end
end

#destroyObject



47
48
49
50
51
52
53
54
# File 'app/controllers/active_metadata/notes_controller.rb', line 47

def destroy
  @document = params[:model_name].to_class.find(params[:model_id])
  @document.delete_note(params[:id])
  respond_to do |format|
    # TODO redirect to index
    format.js
  end
end

#editObject



13
14
15
16
# File 'app/controllers/active_metadata/notes_controller.rb', line 13

def edit
  @document = params[:model_name].to_class.find(params[:model_id])
  @note = @document.note_for params[:field_name],params[:id]     
end

#indexObject



4
5
6
7
8
9
10
11
# File 'app/controllers/active_metadata/notes_controller.rb', line 4

def index
  @document = params[:model_name].to_class.find(params[:model_id])
  @notes = @document.notes_for params[:field_name]
  respond_to do |format|
    format.html { render :layout => false}
    format.xml  { render :xml => @notes }
  end
end

#showObject



18
19
20
21
# File 'app/controllers/active_metadata/notes_controller.rb', line 18

def show
  @document = params[:model_name].to_class.find(params[:model_id])
  @note = @document.note_for params[:field_name],params[:id]     
end

#updateObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/active_metadata/notes_controller.rb', line 32

def update
  @document = params[:model_name].to_class.find(params[:model_id])
  @note = @document.note_for params[:field_name],params[:id]     
        
  respond_to do |format|
    if @document.update_note(params[:id],params[:note][:note])
      format.html { redirect_to((@document.class,@document.id,@note.label,@note.id), :notice => 'Note was successfully updated.') }
      format.xml  { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml  { render :xml => @note.errors, :status => :unprocessable_entity }
    end
  end
end