Sha256: 9d0cb4c721d3c4903fc56bb8109b82b08be9668cdfdf2b9c9bdb745c492aa413

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

class Posts < Merb::Controller
  
  def new
    session[:foo] = 'bar'
    puts session.sess_id
    render
  end  
  
  def create
    @post = Post.create( :title => params[:title], :body => params[:body])
    redirect "/posts/show/#{@post.id}"
  end
    
  def show
    puts session[:foo]
    session[:foo] = 'changed'
    @post = Post.find params[:id]
    @comments = @post.comments
    render
  end
  
  def test
    puts "protocol: #{protocol}"
    puts "ssl?: #{ssl?}"
    puts "uri: #{uri}"
    puts "path: #{path}"
    puts "path_info: #{path_info}"
    puts "port: #{port}"
    puts "host: #{host}"
    puts "domain: #{domain}"
    puts "get?: #{get?}"
    puts "post?: #{post?}"
    puts "put?: #{put?}"
    puts "delete?: #{delete?}"
    puts "head?: #{head?}"
    puts "xhr?: #{xhr?}"
    puts @env.inspect
  end
  
  def xml_test
    render_xml
  end  
  
  def list
    @posts = Post.find :all, :limit => 4
    render
  end  
  
  def add_comment
    puts params.inspect
    @post = Post.find params[:post_id]
    @post.comments.create :name => params[:comment_name],
                          :body => params[:comment_body]
    @comments = @post.comments.reload
    render_js 'comment'
  end
  
  def delete_comment
    @post = Post.find params[:post_id]
    @post.comments.destroy params[:id]
    @comments = @post.comments.reload
    render_js 'comment'
  end  
  
  def index
    list
  end  
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
merb-0.0.7 examples/sample_app/dist/app/controllers/posts.rb