Class: PagePartsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PagePartsController
- Defined in:
- lib/rails/generators/dev_page_install/templates/page_parts_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#destroy ⇒ Object
DELETE /posts/1 DELETE /posts/1.xml.
- #edit ⇒ Object
- #sort ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
2 3 4 5 6 |
# File 'lib/rails/generators/dev_page_install/templates/page_parts_controller.rb', line 2 def create @page_part = PagePart.new(params[:page_part]) @page_part.save redirect_to(:back) end |
#destroy ⇒ Object
DELETE /posts/1 DELETE /posts/1.xml
35 36 37 38 39 40 41 42 43 |
# File 'lib/rails/generators/dev_page_install/templates/page_parts_controller.rb', line 35 def destroy @page_part = PagePart.find(params[:id]) @page_part.destroy respond_to do |format| format.html { redirect_to(:back) } format.xml { head :ok } end end |
#edit ⇒ Object
29 30 31 |
# File 'lib/rails/generators/dev_page_install/templates/page_parts_controller.rb', line 29 def edit @page_part = PagePart.find(params[:id]) end |
#sort ⇒ Object
8 9 10 11 12 13 |
# File 'lib/rails/generators/dev_page_install/templates/page_parts_controller.rb', line 8 def sort order = params['menu'] order.each_with_index do |f, i| PagePart.find(f).update_attribute('sort_order', i) end end |
#update ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rails/generators/dev_page_install/templates/page_parts_controller.rb', line 15 def update @post = Post.find(params[:id]) respond_to do |format| if @post.update_attributes(params[:post]) format.html { redirect_to([:admin, @post], :notice => 'Post was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @post.errors, :status => :unprocessable_entity } end end end |