Habtm has_many through and foreign keys

I have two models
Role and Task
…and a join table/model RoleTask

Now both roles and tasks have id as a primary key and name which is a
unique identifier

I want the join table to hold role_id and task_name

I’ve tried using habtm with foreign key and association foreign keys set
up and I’ve tried using has_many :through
…but they all seem to someone want to work with the primary keys of
both roles and tasks.

Do I need to set the primary key of tasks to be the name field?

thanks in advance
levent