Topic: Beginner: Reference Form?

I have a model artists and now I would like create a model user_artist that  should save the current logged user and a reference to the Artist. I take a new model because there could be later more than one user in this database for one artist.
Now I have the model and how can I save now the current user during the user creates a new Artist.
Here is my current form:
<%= form_for @artist do |f| %>
  <%= f.label :name, "Name" %>
  <%= f.submit "Create" %>
<% end -%>
How I must change this to simultaneously save the user in the database user_artist?

Last edited by freak (2012-12-09 04:17:56)

Re: Beginner: Reference Form?

So you have two models, artist and user_artist, correct?

Your models should have a relationship.
Your controller should pass both objects to the form.
Form in view can display fields for both objects.
Controller saves both objects.

It should go something like that if I understand correctly. If you post your models, controller and view I could try to help more. There should be plenty of tutorials and examples out there for this.

Learning rails, one day at a time.

http://keilmiller.com