Class: ScottyDogSayingsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/scotty_dog_sayings_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#robot?

Instance Method Details

#createObject

POST /scotty_dog_sayings POST /scotty_dog_sayings.xml


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 46

def create
  @scotty_dog_saying = ScottyDogSaying.new(params[:scotty_dog_saying])
  @scotty_dog_saying.user_id = current_user.id if current_user

  respond_to do |format|
    if @scotty_dog_saying.save
      flash[:notice] = 'Thank you for adding to my reprotoire. Scotty Dog Saying was successfully created.'
      format.html { redirect_to(scotty_dog_sayings_path) }
      format.xml { render :xml => @scotty_dog_saying, :status => :created, :location => @scotty_dog_saying }
    else
      format.html { render :action => "new" }
      format.xml { render :xml => @scotty_dog_saying.errors, :status => :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /scotty_dog_sayings/1 DELETE /scotty_dog_sayings/1.xml


81
82
83
84
85
86
87
88
89
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 81

def destroy
  @scotty_dog_saying = ScottyDogSaying.find(params[:id])
  @scotty_dog_saying.destroy

  respond_to do |format|
    format.html { redirect_to(scotty_dog_sayings_url) }
    format.xml { head :ok }
  end
end

#editObject

GET /scotty_dog_sayings/1/edit


40
41
42
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 40

def edit
  @scotty_dog_saying = ScottyDogSaying.find(params[:id])
end

#indexObject

GET /scotty_dog_sayings GET /scotty_dog_sayings.xml


8
9
10
11
12
13
14
15
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 8

def index
  @scotty_dog_sayings = ScottyDogSaying.all

  respond_to do |format|
    format.html # index.html.erb
    format.xml { render :xml => @scotty_dog_sayings }
  end
end

#newObject

GET /scotty_dog_sayings/new GET /scotty_dog_sayings/new.xml


30
31
32
33
34
35
36
37
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 30

def new
  @scotty_dog_saying = ScottyDogSaying.new

  respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @scotty_dog_saying }
  end
end

#showObject

GET /scotty_dog_sayings/1 GET /scotty_dog_sayings/1.xml


19
20
21
22
23
24
25
26
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 19

def show
  @scotty_dog_saying = ScottyDogSaying.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.xml { render :xml => @scotty_dog_saying }
  end
end

#updateObject

PUT /scotty_dog_sayings/1 PUT /scotty_dog_sayings/1.xml


64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/scotty_dog_sayings_controller.rb', line 64

def update
  @scotty_dog_saying = ScottyDogSaying.find(params[:id])

  respond_to do |format|
    if @scotty_dog_saying.update_attributes(params[:scotty_dog_saying])
      flash[:notice] = 'Thanks for giving me something better to say. Scotty Dog Saying was successfully updated.'
      format.html { redirect_to(scotty_dog_sayings_path) }
      format.xml { head :ok }
    else
      format.html { render :action => "edit" }
      format.xml { render :xml => @scotty_dog_saying.errors, :status => :unprocessable_entity }
    end
  end
end