Skip to content

Instantly share code, notes, and snippets.

@dpick
Created March 23, 2011 19:20
Show Gist options
  • Select an option

  • Save dpick/883751 to your computer and use it in GitHub Desktop.

Select an option

Save dpick/883751 to your computer and use it in GitHub Desktop.

Revisions

  1. dpick created this gist Mar 23, 2011.
    1 change: 1 addition & 0 deletions mongoid find_or_create
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    user.restaurants << Restaurant.new(:name => params[:name]) unless user.restaurants.inject { |bool, rest| bool ||= true if rest.name == params[:name] }