views:

10

answers:

0

Hello, I have 3 models: user, wish_list and wishes: user has_one wish_list wish_list has_many wishes

On my index page, I'm listing all the wishes of my current_user's wish_list

in my controller's index method:

@list = current_user.list
@wish= @list.wishes.build

in my index view, I want to put a form to add a new wish on top of the page and then list all wishes.

The creation form on the index view looks like this:

<%= form_for @wish do |f| %>
  <%= f.label :wish_title%>
  <%= f.text_field :wish_title %>
  <%= f.submit %>
<% end %>

I have 2 issues:

  • my form doesn't reference the list_id, so my wish is created without a list_id
  • it adds an empty wish at the end of the list

i'm sure i'm missing something obvious, but I can't put my arms around it.

thanks for your help. pierre