Class: Newsletter::ElementsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Newsletter::ElementsController
- Includes:
- DeleteableActions
- Defined in:
- app/controllers/newsletter/elements_controller.rb
Instance Method Summary collapse
Methods included from DeleteableActions
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/newsletter/elements_controller.rb', line 22 def create @element = Element.new(params[:element]) @element.design = @design respond_to do |format| if @element.save flash[:notice] = 'Element was successfully created.' format.html { redirect_to(design_elements_path(@design)) } format.xml { render :xml => @element, :status => :created, :location => @element } else format.html { render :action => "new" } format.xml { render :xml => @element.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
51 52 53 54 |
# File 'app/controllers/newsletter/elements_controller.rb', line 51 def destroy @element.destroy redirect_to(design_elements_path(@design)) end |
#edit ⇒ Object
19 20 |
# File 'app/controllers/newsletter/elements_controller.rb', line 19 def edit end |
#index ⇒ Object
9 10 11 12 |
# File 'app/controllers/newsletter/elements_controller.rb', line 9 def index @elements = @design.elements. by_design(@design).paginate(:page => params[:page]) end |
#new ⇒ Object
14 15 16 17 |
# File 'app/controllers/newsletter/elements_controller.rb', line 14 def new @element = Element.new @fields = [Field.new] end |
#update ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/newsletter/elements_controller.rb', line 38 def update respond_to do |format| if @element.update_attributes(params[:element]) flash[:notice] = 'Element was successfully updated.' format.html { redirect_to(design_elements_path(@design)) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @element.errors, :status => :unprocessable_entity } end end end |