Created
August 11, 2009 20:20
-
-
Save bkeepers/166088 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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