1

Gemfile

gem 'rails', '~> 4.2', '>= 4.2.5'
gem 'userstamp', :git => 'https://github.com/stricte/userstamp.git', :branch => 'rails4'

User model

class User < ActiveRecord::Base
  ...
  model_stamper
  stampable
  ...
end

I have this message

You tried to define an association named creator on the model User, but this will conflict with a method creator already defined by Active Record. Please choose a different association name. (ArgumentError)

How I can fix it?

Nikolay Lipovtsev
  • 657
  • 1
  • 6
  • 15

1 Answers1

0

You need to customize your stampable call as suggested in the docs.

It should be something like that:

acts_as_stampable :stamper_class_name => :person,
                  :creator_attribute  => :create_user,
                  :updater_attribute  => :update_user,
                  :deleter_attribute  => :delete_user

The problem is that Active record is creating a method called creator and the gem is trying to do the same since this is the default behaviour. Change the creator attribute should be enough. But you have all those options to customize.

Cassio Cabral
  • 2,652
  • 3
  • 23
  • 37
  • If I add this code at User model user.rb, I get this error: `undefined method acts_as_stampable' for #` class User < ActiveRecord::Base model_stamper acts_as_stampable :stamper_class_name => :person, :creator_attribute => :create_user, :updater_attribute => :update_user, :deleter_attribute => :delete_user end – Nikolay Lipovtsev Dec 26 '15 at 13:09
  • This is just an example, it won't work just by pasting it. That's how the docs suggests when you need a custom name for your methods. Since the creator methods is causing trouble you should find a way to adapt that code to your needs and will make it work. You should look more into the docs for how to adapt to your needs. Knowing that creator is the one causing conflicts you can try to solve or open a issue in the project github page telling your conflict with active record. – Cassio Cabral Dec 26 '15 at 16:23