Class: ContentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ContentsController
- Defined in:
- lib/generators/contentment/templates/contents_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 28 def create @content = Content.new(params[:content]) respond_to do |format| if @content.save format.html { redirect_to edit_content_path(@content.id), :notice => 'Content was successfully created.' } else format.html { redirect_to new_content_path, :notice => "There was a problem creating that content" + @content.errors..join(', ') } end end end |
#destroy ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 51 def destroy @content = Content.find(params[:id]) @content.destroy respond_to do |format| format.html { redirect_to(contents_url) } end end |
#edit ⇒ Object
24 25 26 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 24 def edit @content = Content.find(params[:id]) end |
#index ⇒ Object
3 4 5 6 7 8 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 3 def index @contents = Content.order("tipe ASC, position ASC") respond_to do |format| format.html end end |
#new ⇒ Object
17 18 19 20 21 22 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 17 def new @content = Content.new respond_to do |format| format.html end end |
#show ⇒ Object
10 11 12 13 14 15 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 10 def show @content = Content.find(params[:id]) respond_to do |format| format.html end end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/contentment/templates/contents_controller.rb', line 39 def update @content = Content.find(params[:id]) @content.update_attributes(params[:content]) respond_to do |format| if @content.save format.html { redirect_to edit_content_path(@content.id), :notice => 'Content was successfully updated.' } else format.html { redirect_to new_content_path, :notice => "There was a problem updating that content" + @content.errors..join(', ') } end end end |