Posted By

pdxmph on 04/01/11


Tagged


Versions (?)

reclasser.rb


 / Published in: Ruby
 

  1. #!/usr/bin/env ruby
  2.  
  3. require 'rubygems'
  4. require 'sinatra'
  5. require 'active_record'
  6. require 'active_support'
  7. require '/Users/mike/lib/ruby/CDEV'
  8.  
  9. ActiveRecord::Base.establish_connection(
  10. :adapter => "sqlite3",
  11. :database => "/Users/mike/desktop/reclass.sqlite3"
  12. )
  13.  
  14. class Article < ActiveRecord::Base
  15.  
  16. end
  17.  
  18. set :public, File.dirname(__FILE__) + '/pub'
  19.  
  20. layout 'default.rhtml'
  21.  
  22. get '/article/:id' do
  23. @article = Article.find(params[:id])
  24. erb :show
  25. end
  26.  
  27. get '/summary/:id' do
  28.  
  29. @article = Article.find(params[:id])
  30. @web = CDEV.new(@article.url).summarized
  31. erb :summary
  32. end
  33.  
  34.  
  35. post '/article/:id/update' do
  36.  
  37. id = params[:id].to_i
  38.  
  39. @article = Article.find(params[:id])
  40. @article.update_attribute(:reclass_to, params[:reclass_to])
  41.  
  42. redirect "/article/#{id + 1}"
  43.  
  44. end
  45.  

Report this snippet  

You need to login to post a comment.