Class: TextsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/texts_controller.rb', line 17

def create
  @text = @owner.texts.build(params[:text])
  if @owner.save
    flash[:notice] = "Successfully created text."
    redirect_to :back
  else
    render :action => 'new'
  end
end

#destroyObject



42
43
44
45
46
47
# File 'app/controllers/texts_controller.rb', line 42

def destroy
  @text = Text.find(params[:id])
  @text.destroy
  flash[:notice] = "Successfully destroyed text."
  redirect_to :back
end

#editObject



27
28
29
30
# File 'app/controllers/texts_controller.rb', line 27

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

#indexObject



3
4
5
# File 'app/controllers/texts_controller.rb', line 3

def index
  @texts = Text.all
end

#newObject



11
12
13
14
15
# File 'app/controllers/texts_controller.rb', line 11

def new
  @index = Index.find(params[:index_id])
  @text = @index.texts.build(:priority => ((@index.texts.first.lowest_priority + 1) rescue 0))
  render :layout => false
end

#showObject



7
8
9
# File 'app/controllers/texts_controller.rb', line 7

def show
  @text = Text.find(params[:id])
end

#updateObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/texts_controller.rb', line 32

def update
  @text = Text.find(params[:id])
  if @text.update_attributes(params[:text])
    flash[:notice] = "Successfully updated text."
    redirect_to :back
  else
    render :action => 'edit'
  end
end