Rails has_many with alias name
You could also use alias_attribute
if you still want to be able to refer to them as tasks as well:
class User < ActiveRecord::Base
alias_attribute :jobs, :tasks
has_many :tasks
end
Give this a shot:
has_many :jobs, foreign_key: 'user_id', class_name: 'Task'
Note, that :as
is used for polymorphic associations.
Also, foreign_key option for has_many.