Permalink
Browse files

first or create

  • Loading branch information...
1 parent 3d11e33 commit 397be2fcbab0d6350b737aa0c0e6bbfad6ef228a Sausheong Chang committed May 22, 2009
Showing with 1 addition and 2 deletions.
  1. +1 −2 snip.rb
View
@@ -5,8 +5,7 @@
post '/' do
uri = URI::parse(params[:original])
raise "Invalid URL" unless uri.kind_of? URI::HTTP or uri.kind_of? URI::HTTPS
- @url = Url.first(:original => uri.to_s)
- @url = Url.create(:original => uri.to_s) if @url.nil?
+ @url = Url.first_or_create(:original => uri.to_s)
haml :index
end

0 comments on commit 397be2f

Please sign in to comment.