Skip to content

Instantly share code, notes, and snippets.

@masterkain
Created August 1, 2011 00:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masterkain/1117385 to your computer and use it in GitHub Desktop.
Save masterkain/1117385 to your computer and use it in GitHub Desktop.
# @topic = Topic.new(params[:topic])
# @topic.this_user = current_user
class Topic < ActiveRecord::Base
belongs_to :user
attr_accessor :this_user
def validate_on_update
# Make sure that this_user is an instance of User, otherwise just use the id
errors.add(:user, "Only the topic creator can update the topic") if user_id != this_user.id;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment