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 Kostov. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Kostov <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 athttp://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 Kostov. > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I know how to save the record, the problem is to generate the form. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Kostov <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I know how to save the record, the problem is to generate the form. > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Kostov <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>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. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Kostov <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 Kostov <rails-mailing-l...@andreas-s.net> > > 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. > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---