pjb3 (owner)

Revisions

gist: 155906 Download_button fork
public
Public Clone URL: git://gist.github.com/155906.git
Embed All Files: show embed
action_with_case.rb #
1
2
3
4
5
6
7
8
9
class WeblogController < ActionController::Base
  def index
    @posts = Post.find :all
    case format
      when :xml then render :xml => @posts.to_xml
      when :rss then render :action => "feed.rxml"
    end
  end
end
action_with_respond_to.rb #
1
2
3
4
5
6
7
8
9
10
11
class WeblogController < ActionController::Base
  def index
    @posts = Post.find :all
    respond_to do |format|
      format.html
      format.xml { render :xml => @posts.to_xml }
      format.rss { render :action => "feed.rxml" }
    end
  end
end