nil returns false, so
if @tourscheduler_user.tourscheduler_id &&
@tourscheduler_user.tourscheduler_id == @tourscheduler.id then
...id and matching...
...no id or not matching...
But there are several issues with this approach.
1) if you use tourscheduler_id, then there should always be a
tourscheduler matching it
Otherwise your db is inconsistent. If you delete a tourscheduler you
sure, it's not referenced anymore...
2) It's not very rails like
You should define
in tourscheduler_user model
in tourscheduler model and use the rails methods to handle
Then your code would be simply:
if @tourscheduler_user.tourscheduler then