Question: answers\_controller:

```
@questions = Question.order("qtype, position")
@ans = Answer.where(user_id = current_user.id)
@answers = @questions.map { |q| [q, @ans.find_by_question_id(q.id)] }

```

view:

```
<%= form_for @answers, :remote => true do |form| %>

```

Is the error because @answers is is mapped? Any help is appreciated.

UPDATE:

Answer model:

```
belongs_to :user
belongs_to :question

```

User model:

```
has_many :answers

```

Question model:

```
has_many :answers

```

UPDATE 2:
I copied and pasted the following into the controller.

```
@answers = current_user.answers.questions

```

I got the following:

```
undefined method `questions' for #<Class:0x1032d6d98>

```

I tried going adopting the second approach - User model:

```
has_many :answers, :through => :answers

```

controller:

```
@questions = current_user.questions

```

and got:

```
undefined method `questions' for #<User:0x103569ec0>
app/controllers/answers_controller.rb:18:in `index'

```

Answer: 
Yes, this is the reason. You probably wanted to do:
 current\_user.answers.questions

Which, if you have your associations set as needed, will return exactly what you want (by using joins behind the scenes)

update:

Now, by looking at your associations, I'm not sure, what you're trying to accomplish.
Won't @answers = current\_user.answers return all answers, and then in the view you can use answer and corresponding question (and still use form\_for @answers).
However if you want to have @questions instead, you can do something like this:

First, associate user with questions

```

class User
  has_many :questions, :through => :answers
end

```

The in your controller:

```

@questions = current_user.questions

```

Hope that it helps.
If I understand correctly, you want to list all answers, but in the same order as your questions.

I am assuming your models look like

```
class User
  has_many :questions, :through => :answers
  has_many :answers
end

class Question
  has_many :answers
  has_many :users, :through => :answers
end

class Answer
  belongs_to :user
  belongs_to :question 
end

```

Getting the questions of the `current_user` should then just become:

```
@questions = current_user.questions.order("qtype, position")

```

getting the corresponding answers then becomes

```
@answers = @questions.map{|q| q.answer}

```

Hope this helps.