I believe you are incorrect. With
__PACKAGE__->many_to_many( roles => 'user_roles', 'role_id' );
I receive this error:
Couldn't render template "books/list.tt2: undef error - search_related: result source
'UserRole' has no such relationship role_id at /usr/lib/perl5/site_perl/5.12.3/DBIx/Class/
Schema.pm line 1071
With
__PACKAGE__->many_to_many( roles => 'user_roles', 'role' );
I receive no error.
See the other many_to_many relationships:
lib/MyApp/Schema/Result/Book.pm
89:__PACKAGE__->many_to_many( 'authors', 'book_authors', 'author' );
lib/MyApp/Schema/Result/UserRole.pm
84:__PACKAGE__->many_to_many( users => 'user_roles', 'user' );
lib/MyApp/Schema/Result/BookAuthor.pm
84:__PACKAGE__->many_to_many( 'books', 'book_authors', 'book' );
None of them refer to any *_id.
Catalyst 5.80032
Catalyst::Helper::Model::DBIC::Schema 0.50