Help needed in rails view

Hi, guys.
I’m new in Rails and now I’m playing around with it.
I’m writing simple test system. The basic stuff is at
http://pastie.org/233197
The thing is I don’t know how to get the answer and the suggestions and
put them in html form with radio buttons.

Thanks in advance.
Mitko K…

I find it easier to debug model relationships in the console as
opposed to the browser… try (this is a guess as to your schema,
change attributes as needed of course)

$ script/console

q = Question.create :content=>“where’s the beef?”, :user=>“guest”
=> true
q.answer = Answer.create :content=>“in my belly”, :user=>“fat bastard”
=> true
q.suggestions
=> []
q.suggestions << Suggestion.create :content=>“look in the fridge”
=> true

When accessing these resources you’ll probably want to only reference
an answer within the context of it’s question. Your routes.rb file (in
config) should include:

map.resources :questions, :has_one => :answer\

I recommend you pick up ‘Advanced Rails Recipes’ and read Adam
Wiggins’ recipe regarding nested resources. HTH.

SH

On Jul 14, 11:52 am, Mitko K. [email protected]

I know how to save the record, the problem is to generate the form.

Do you want to access the answer in the question form? Your pastie
looks like a form_for @question… Or do you want to create a form_for
@answer (scoped to it’s question)?

I don’t think I understand what the radio buttons should do either,
can you explain more the form please? thx

On Jul 14, 1:20 pm, Mitko K. [email protected]

I haven’t used radio buttons enough to know how to do this without
playing with it … check out Softie’s on Rails “Absolute Moron’s
Guide to Forms in Rails”
http://www.softiesonrails.com/2008/4/8/absolute-moron-s-guide-to-forms-in-rails-part-4.

Number 4 deals specifically with radio buttons and it should help
you, I found all five to be helpful. You’ll probably want to randomize
the order of your answer and suggestions so the answer isn’t always
“C” or something… I’d be interested to see how you do that.

SH

On Jul 14, 2:41Â pm, Mitko K. [email protected]

shenry wrote:

Do you want to access the answer in the question form? Your pastie
looks like a form_for @question… Or do you want to create a form_for
@answer (scoped to it’s question)?

I don’t think I understand what the radio buttons should do either,
can you explain more the form please? thx

On Jul 14, 1:20�pm, Mitko K. [email protected]
I’ve got questions tabel, answers table and suggestions table.
And when I want to make a test I want to get a question content, answer
and suggestions foru this question. Then I want to put the answer and
the suggestions into radio buttons :
http://img135.imageshack.us/img135/4080/picture1zj9.png

Thanks.