Skip to content

Commit

Permalink
first or create
Browse files Browse the repository at this point in the history
  • Loading branch information
Sausheong Chang committed May 22, 2009
1 parent 3d11e33 commit 397be2f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions snip.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
post '/' do post '/' do
uri = URI::parse(params[:original]) uri = URI::parse(params[:original])
raise "Invalid URL" unless uri.kind_of? URI::HTTP or uri.kind_of? URI::HTTPS raise "Invalid URL" unless uri.kind_of? URI::HTTP or uri.kind_of? URI::HTTPS
@url = Url.first(:original => uri.to_s) @url = Url.first_or_create(:original => uri.to_s)
@url = Url.create(:original => uri.to_s) if @url.nil?
haml :index haml :index
end end


Expand Down

0 comments on commit 397be2f

Please sign in to comment.