class ContentsController < ApplicationController # GET /users # GET /users.xml # GET /users.fxml def index @contents = Content.find(:first).descendants respond_to do |format| format.html # index.html.erb format.fxml do render :fxml => @contents end format.xml do render :xml => @contents end end end # GET /users/1 # GET /users/1.xml # GET /users/1.fxml def show @content = Content.find(params[:id]) @content_assignments = [] @procs ContentAssignment.find(:first, :conditions => {:content_id => @content.id}).descendants.each do |child| proc = Proc.new do |opts| opts[:builder].tag!('parent_id', child.parent.content.id) end @content_assignments.push(child) @procs.push(proc) end respond_to do |format| format.html # index.html.erb format.fxml do render :fxml => @content.to_fxml(:child_proc => @procs) end format.xml do render :xml => @content.to_fxml(:child_proc => @procs) end end end # GET /users/new # GET /users/new.xml def new @content = Content.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @content } end end # GET /users/1/edit def edit @content = Content.find(params[:id]) end # POST /users # POST /users.xml # POST /users.fxml def create @content = Content.new(params[:content]) respond_to do |format| if @content.save flash[:notice] = 'Content was successfully created.' format.html { redirect_to(@content) } format.xml { render :xml => @content, :status => :created, :location => @content } format.fxml { render :fxml => @content } else format.html { render :action => "new" } format.xml { render :xml => @content.errors, :status => :unprocessable_entity } format.fxml { render :fxml => @content.errors } end end end # PUT /users/1 # PUT /users/1.xml # PUT /users/1.fxml def update @content = Content.find(params[:id]) respond_to do |format| if @content.update_attributes(params[:content]) flash[:notice] = 'Content was successfully updated.' format.html { redirect_to(@content) } format.xml { head :ok } format.fxml { render :fxml => @content.to_fxml } else format.html { render :action => "edit" } format.xml { render :xml => @content.errors, :status => :unprocessable_entity } format.fxml { render :fxml => @content.errors } end end end # DELETE /users/1 # DELETE /users/1.xml # DELETE /users/1.fxml def destroy @content = Content.find(params[:id]) @content.destroy respond_to do |format| format.html { redirect_to(contents_url) } format.xml { head :ok } format.fxml { render :fxml => @content } end end end