Advertisement
Guest User

router (controller)

a guest
Apr 7th, 2013
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.60 KB | None | 0 0
  1. # coding: utf-8
  2. require 'sequel'
  3.  
  4. module Post
  5.     @@DB=Sequel.sqlite
  6.     @@DB.create_table :post do
  7.         primary_key :id
  8.         String :title
  9.         Text :body
  10.         String :tags
  11.         String :option
  12.         String :username
  13.         Integer :user_id
  14.     end
  15.     @@post=@@DB[:post]
  16.     def Post.add(params, user_info)    
  17.         @@post.insert(
  18.             :body=>params[:body],
  19.             :title=>params[:title],
  20.             :tags=>params[:tags],
  21.             :username=>user_info[:username],
  22.             :user_id=>user_info[:id],
  23.             :option=>user_info[:option]
  24.         )
  25.     end
  26.     def Post.get_all(params)
  27.         @@post.all
  28.     end
  29.     def Post.get_id(params)
  30.         @@post[:id=>params[:post_id].to_i]
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement