Question: I'm working on a scavenger hunt app and I'm stuck. So I've set up the CRUD for the hunts and for the tasks associated with hunts. But I don't know how to set it up so that the user can associate a particular task with a particular hunt. I think I've got the models setup correctly, but I'm not really sure how to setup the views that allow this association of tasks with a hunt. 

```
class Hunt < ActiveRecord::Base

  has_many :tasks
  attr_accessible :name
  validates :name,  :presence => true,
                    :length   => { :maximum => 50 } ,
                    :uniqueness => { :case_sensitive => false }

end

class Task < ActiveRecord::Base

  belongs_to :hunts
  attr_accessible :name
  validates :name,  :presence => true,
                    :length   => { :maximum => 50 } ,
                    :uniqueness => { :case_sensitive => false }

end

```

I'm guessing I need write a view that shows a hunt and then lists all the available tasks. Then I need a way to for the user to "pick" a task and add it to a hunt. It's this last part that has me stumped.

Answer: 
> 
> I'm guessing I need write a view that shows a hunt and then lists all the available tasks. Then I need a way to for the user to "pick" a task and add it to a hunt. It's this last part that has me stumped.
> 
> 
> 

Above implies that there's a `has_and_belongs_to_many` (`*..*`) relationship between `Hunt` and `Task` and not `has_many` (since a Hunt can be associated with multiple Tasks and a Task can belong to multiple Hunts within your system).

You could go with:

```
class Hunt < ActiveRecord::Base
  [...]
  has_and_belongs_to_many :tasks
  [...]
end # Hunt

class Task < ActiveRecord::Base
  [...]
  has_and_belongs_to_many :hunts
  [...]
end

```

Doing so shall enable you to associate multiple Tasks (or you could associate just one if you want) and also having a Task belong to more than one Hunts. Further, you could go with a simple `f.select` form tag helper to render a list of available Tasks in your system.

Hope this helps.
Your `belongs_to` declaration in the `Task` class should be for `:hunt`, not `:hunts`.

As far as the view goes, it's pretty simple. Just use `f.select` (assuming your form helper variable name is `f`) on `:hunt_id`, and update the `hunt_id` attribute inside `Task`.

This will associate the `Hunt` with the `Task`.

Be sure to check out `options_for_select`, so you can display the `Hunt` name with the `hunt_id` option value in the form. I also recommend reading through the Rails guide on associations: <http://guides.rubyonrails.org/association_basics.html>