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.

On Wed, Dec 21, 2016 at 10:10 AM, Nazar Matus <[email protected]>
wrote:

> 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.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to