Skip to content

Instantly share code, notes, and snippets.

@bkeepers
Created August 11, 2009 20:20
Show Gist options
  • Save bkeepers/166088 to your computer and use it in GitHub Desktop.
Save bkeepers/166088 to your computer and use it in GitHub Desktop.
class Position < ActiveRecord::Base
attr_protected :account_id, :created_at, :updated_at
belongs_to :account
#### Option 1 ####
attr_restricted :job_id
# assigns attribute if this method returns true
def allow_job_id_assignment?(id)
account.jobs.find_by_id(id) if account
end
#### Option 2: with a block ####
attr_restricted :job_id do |id|
account.jobs.find_by_id(id) if account
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment