title: ActiveRecord Cannot save a record: "zero-length delimited identifier"
body: <p>I'm working on a project that allows users to rate recipes. I made a simple join table (RecipeRating) that User and Recipe both share, but ActiveRecord is having trouble saving.</p>
  
  <pre><code>@rating = @user.recipe_ratings.where(:recipe_id =&gt; @recipe.id).first
  @rating.rating = params[:rating]
  @rating.save
  </code></pre>
  
  <p>Yields:</p>
  
  <pre><code>ActiveRecord::StatementInvalid in UsersController#rate_recipe
  PG::Error: ERROR:  zero-length delimited identifier at or near """"
  LINE 1: ...013-08-07 14:28:39.965953' WHERE "recipe_ratings"."" IS NULL
                                                               ^
  : UPDATE "recipe_ratings" SET "rating" = 3, "updated_at" = '2013-08-07 14:28:39.965953' WHERE "recipe_ratings"."" IS NULL
  </code></pre>
  
  <p>Clearly the error is caused by <code>WHERE "recipe_ratings"."" IS NULL</code>  but what is causing this and how do I fix it? For reference, it's having no trouble creating or finding ratings (which are saved as expected in my db), it just can't update them.</p>
  
  <p>For reference:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    ...
    has_many :recipe_ratings
  end
  
  class Recipe &lt; ActiveRecord::Base
    ...
    has_many :recipe_ratings
  end
  
  class RecipeRating &lt; ActiveRecord::Base
    belongs_to :recipe
    belongs_to :user
    attr_accessible :comment, :rating, :user, :recipe#, :user_id, :recipe_id
  end
  </code></pre>