Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force validation for updating instructorship.instructor_id when merging ... #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/instructor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def eat(victims)

things.each do |thing|
puts " updating #{thing.inspect}"
raise "Failed update" unless thing.update_attribute(:instructor_id, self.id)
raise "Failed update" unless thing.update_attributes(:instructor_id => self.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#update_attributes! will raise an exception if validation fails, so you can just use that.

Also, unrelated to this change, but we really shouldn't be putting random print statements in the code like on line 59.

Other nitpick unrelated to this change: def eat(victims)? Really?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was quite amused by the usage of "things" as a variable name, made it really clear what I was looking at...

thing.reload
raise "Failed check" unless thing.instructor_id == self.id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to do this check?

end
Expand Down