Sha256: 996332013ab5748ae21bfe5300a80a238ea17ce3eb7a3459d513700262193de0

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

class Posts < Merb::Controller
  
  def access_denied
    render
  end  
    
  def new
    #session[:foo] = 'foo'
    #puts session.session_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 "request.protocol: #{request.protocol}"
    puts "request.ssl?: #{request.ssl?}"
    puts "request.uri: #{request.uri}"
    puts "request.path: #{request.path}"
    puts "request.path_info: #{request.path_info}"
    puts "request.port: #{request.port}"
    puts "request.host: #{request.host}"
    puts "request.domain: #{request.domain}"
    puts "request.get?: #{request.get?}"
    puts "request.post?: #{request.post?}"
    puts "request.put?: #{request.put?}"
    puts "request.delete?: #{request.delete?}"
    puts "request.head?: #{request.head?}"
    puts "request.xhr?: #{request.xhr?}"
    puts request.inspect
  end
  
  def xml_test
    render_xml
  end  
  
  def list
    #session[:foo] = 'hi'
    @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  

end 

Version data entries

1 entries across 1 versions & 1 rubygems

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