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.  
  24. @article = Article.find(params[:id])
  25. @web = CDEV.new(@article.url)
  26. erb :show
  27.  
  28. end
  29.  
  30.  
  31. post '/article/:id/update' do
  32.  
  33. id = params[:id].to_i
  34.  
  35. @article = Article.find(params[:id])
  36. @article.reclass_to = params[:reclass_to]
  37. @article.save
  38.  
  39. if Article.find(:first, :conditions => ["id = ?", id + 1])
  40. redirect "/article/#{id + 1}"
  41. else
  42. redirect "/article/#{id}"
  43. end
  44. end
  45.  

Report this snippet  

You need to login to post a comment.