Guest User

Untitled

a guest
May 26th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. get '/articles' do
  2. articles = Article.all
  3. puts "Article number: #{articles.length}"
  4. haml :blog, :locals => { :articles => articles }
  5. end
  6.  
  7. post '/articles' do
  8. article = Article.new
  9.  
  10. article.id = params[:id]
  11. article.type = params[:type]
  12. article.type ||= 'Article'
  13. article.title = params[:title]
  14. article.slug = (s = params[:slug]) ? s : params[:title].downcase.gsub(' ','-')
  15. article.author = Author.get(params[:id])
  16. article.date = Date.parse params[:date]
  17. article.body = params[:body]
  18.  
  19. article.save
  20. end
Add Comment
Please, Sign In to add comment