> And just to confirm, you are doing this in the user controller, right?

Yes this is all happening in the user model

> What do your models look like for wishlist and user then? If you have
> defined the has_many belongs_to relationship, then the one-liner I
> showed you:

My user model has a: has_one: wishlist
My wishlist model: belongs_to: user

>  @wishlist = current_user.wishlists.create(params[:wishlist])
>
> should create the relationship and build and save the wishlist.

I have put as you said:

before_filter :set_wishlist, :only => :create

  def set_wishlist
    current_user.wishlists.create(params[:wishlist])
  end

But now I have errors return back stating:

undefined method `wishlists' for nil:NilClass

If I change it to wishlist I get the same error as well as Wishlist. If 
I state params in the def set_wishlist(params) it returns aargument (0 
of 1) error.

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to