has_many through additional (default) attribute values for through record on adding

For example, I have a User, Achievement and AchievementDate.
class User < ApplicationRecord
has_many :achievement_dates
has_many :achievements, through: :achievement_dates
end

``

And when I write add an achievement like this:
user.achievements << achievement

``

I want through record to be initialized with current date. So I want something like this:

class User < ApplicationRecord
has_many :achievement_dates
has_many :achievements, through: :achievement_dates, initialize_with: :method_name

private

def method_name(achievement_date)
achievement_date.date = Date.current
end
end

``

Currently I could not find a good way to achieve such behavior in Rails 5.0.0.1, so please, give me some advice or feedback.

This mailing list (rubyonrails-core) is intended for discussion about development of the framework itself, not usage of it.

For support issues or usage questions like this one that are not issues with Rails itself, please post to the rubyonrails-talk mailing list (http://groups.google.com/group/rubyonrails-talk) or somewhere like StackOverflow using the ruby-on-rails tag (http://stackoverflow.com/questions/tagged/ruby-on-rails). You can also drop in to the #rubyonrails channel on irc.freenode.net for realtime help. You’ll be more likely to get a quick answer using one of those options.