Rails 3 - Making a Form for Project/Permissions

Hello, I have the following Models:
Permissions (user_id, role_id, project_id)
Roles (id, name)
Projects (id, name)

I’m struggling to make a form to allow a user to either Add or Update
a User’s Project permission

Here’s what I have so far:

<%=form_for [@project,Permission.new], :remote => true do |f|%>

<%= f.collection_select("permission", "role_id", @roles, "id") %>

<% end %>

What I want to happen on this form, is for it to show a dropdown of
available roles, and if the user is currently assigned to a role to
have that as the selected setting. If not, for the select dropdown box
to be blank.

Then if the user changes the select drop down, for it to post the
update back to the server. Where the controller would either create or
update (depending on if the user had a previous permission for a
project).

Can you help walk me through the flow of setting this up? thank you!