search for: question_id

Displaying 19 results from an estimated 19 matches for "question_id".

2006 Apr 04
2
Syntax Error in find()
Maybe I misunderstand the parameterization of find(), I am getting this syntax error for <% @choices = Choic e.find(:all, :conditions => "question_id" = question.id, :order => "order") %> ---- ERROR LOG ---- ActionView::TemplateError (compile error ../config/../app/views/admin/test/show.rhtml:37: syntax error _erbout.concat " "; @choices = Choice.find(:all, :conditions => "question_id" = ques...
2006 Jul 01
4
Radio_button in loop problem
...he values stored in my database. I read through some of the previous posts -- is it true that they don''t work with integers? This is the code I''m using: <% for question in @survey.questions %> <%= debug question %> <%= radio_button ( "question", :question_id, question.option_one.id) %> <%= question.option_one %> <%= radio_button ( "question", :question_id, question.option_two.id) %> <%= question.option_two %> <% end %> The "debug question" statement prints out the correct values. I have to thin...
2006 Jan 04
4
many to many link table compound primary key explosion
...primary key from the two fields to prevent duplicate records. When I add the same answer to the same question more than once, rails attempts to create a duplicate record and explodes with a MySQL error: MysqlError: Duplicate entry ''3-3'' for key 1: INSERT INTO answers_questions (`question_id`, `answer_id`) VALUES (3, 3) Now, I realise I can fix this by removing the primary key from my schema, and some would say the primary key is unnecessary, but I think Rails'' behaviour is wrong. Any thoughts? MySQL in particular supports "ON DUPLICATE KEY UPDATE" which would hel...
2006 Jan 19
8
Passing variables across forms
...swer # the new answer must belong to a question... so I wasn''t sure # whether to call it new answer or add answer. @question = Question.find(params[:id]) @answer = Answer.new @question.answers << @answer end def create_answer @answer = Answer.new(params[:question_id]) if @answer.save flash[:notice] = ''Answer was added to the question.'' redirect_to :action => ''show'', :id => @question else render :action => ''create_answer'' end end ########################### #########...
2006 Jun 04
4
Multiple checkboxes
...; <input type="checkbox" name="option[]" value="<%=option.id%>"><%= option.option_text %></br> <% end %> </br> <%= submit_tag%> <%= end_form_tag%> Controller: def save_question @options = Option.find_all_by_question_id(session[:question_id]) response = "" for option in @options do if params[:option][option.id]=="1" response << "1" else response << "0" end end end -- Posted via http://www.ruby-forum.com/.
2006 Mar 08
0
Unit tests dynamic finders
...dels (B depends on A) deleting A should also delete B. This is simple with the dependent parameter in the model file of A. But when I write a test the dependency seems to work, I can''t find the answer with id 1 anymore(Answer.find(1)). But I appearently _do_ find it with Answer.find_by_question_id(1) or Answer.find(:first, :conditions => "question_id = 1"). What am I doing wrong?? Below you will find the relevant files used in testing. questions.yml: first_question: id: 1 question: "Will fixture files work?" answer: "No" answers.yml: first_answer:...
2006 Apr 02
5
adding primary_key to join table using migrations
Hi list, My tag_question_user join table is not currently a full-blown model. It doesn''t have a primary key - just tag_id, question_id, and user_id. I now want to add a primary key to this model (because I want to add a "description" column as well so users can describe the tag. I''m not sure how to add this using migrations. Here is what I have: class AddNotesToTags < ActiveRecord::Migration def self.up...
2006 Aug 07
1
Unable to page.replace_html from rjs
...ate, and the div updates fine. Does anyone have any idea why this might be happening? In the partial: <div><div> . . <div id="question_<%=question.id%>_error"></div> . (if a link_to_remote is here it works) . In the rjs: page.replace_html "question_#{question_id}_error", "foobar" Thanks! -- Posted via http://www.ruby-forum.com/.
2006 Mar 10
0
Multiple radio buttons for defining multiple objects?
Hi, I''ve been working on a multiple choice Question/Answer system. The response object (analagous to a lineitem) has a question_id, user_id, and the actual response. What''s a good way of making a form with multiple response objects which are created from the radio_button helper? Right now I''ve got the following code: ################################################## <%= start_form_tag :action =>...
2011 Apr 21
0
Get data from 2 tables
Hi, i have 4 tables: questions, answers, users, and inquiries (relationship) def index question_id = params[:id].to_i question = Question.find(question_id) @answers = question.answers respond_to do |format| format.ext_json { render :json => @answers.to_ext_json(:class => Answer) } end end I have several scaffold in extjs, when I click on row, i get answers o...
2012 Oct 06
0
rails 3.2 question/answer with a through table
...l-label'' %> <div class="controls"> <% if question.data_type == ''select'' %> <%= pregunta.send(question.data_type, :answer, question.to_select,:class => "#{question.data_type}") %> <%= pregunta.hidden_field :question_id, :value => question.id , :class => "#{question.data_type}" %> <% else %> <%= pregunta.send(question.data_type, :answer, :class => "#{question.data_type}" ) %> <%= pregunta.hidden_field :question_id, :value => question.id , :class...
2012 May 02
2
Column with dynamic db type
Hi, I have a Question model where the answer to the question can have multiple db type (integer, string, boolean, ...). I would like to know if you have a better solution than this one: Question: question:string answer_type:string AnsweredQuestion: question_id:integer answer:text answer_type:string Ex: AnsweredQuestion.create(:question => 1, :answer => ''5'', :answer_type => ''Integer'') My problem with this solution is that I can''t question is that I can''t question the answered questions where...
2006 Jun 02
7
Unit Tests crashing out for a table without an ID
I''m having problems unit testing my model- I have a kind of quiz functionality user table and a question table and a user_question_response table that contains the id for the user, the id for the question and the user''s response. The user_question_response has it''s own model belongs_to/has_many with users and questions and it works fine in the actual application but
2009 Feb 27
5
Polymorphic association..explain the extra query ?
Can anyone explain to me the sql query done in the last step : http://pastie.org/402200 -- Arpit Jain --~--~---------~--~----~------------~-------~--~----~ 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,
2012 Sep 29
0
rails 3.2 nested form names not correct
...t;> <%= pregunta.label question.name, (question.label_text unless question.label_text.nil?), :class => ''control-label'' %> <div class="controls"> <%= pregunta.send(question.data_type, :option_selected ) %> <%= pregunta.hidden_field :question_id, :value => question.id , :class => "#{question.data_type}" %> </div> </div> Is there a way to get the attribute names to be correct? The questions come from the db. chrome inspector: <input id="person_person_questions_attributes_0_option_selected" n...
2011 Mar 28
0
Token Poken :( I'm stuck with this
...w1.to_s) @answers=Hash.new questions = Question.find(:all,:conditions=>"enabled=1") questions.each do |question| if params["answer_"+question.id.to_s] @answers[question.id]=params["answer_"+question.id.to_s] if !Answer.create(:question_id=>question.id,:token=>@w,:text=>params["answer_"+question.id.to_s]) flash[:error]="Can`t create answer!" end end end if !flash[:error] redirect_to :action=>"pass" return false end end def index...
2006 Apr 02
2
"Quiz" site
Hi, I am thinking about how to best design a quiz site in RoR. I think it should be fairly easy, but have run into a wall. In the simplest form, the view would grab all of the questions for a particular quiz and display them (e.g. multiple choice, so 4 option buttons per question). However, I can''t figure out how to "mark" the quiz. The form is submitted to the
2010 Mar 10
6
Email section
Sir , I want to implement email section in ma web application.. so i found the method ''server_setting'' for it... Following is the method: config.action_mailer.server_settings = { :address => "smtp.gmail.com" , :port => 25, :domain => "gmail.com" , :authentication => :login, :user_name => "manish" , :password =>
2006 Jan 18
22
Creating multiple child objects from the same form
...the answer choices. But with my code, I can only do one successful child creation. The log only shows that one answer is being passed in. Here''s the code as of right now: ############ models class Answer < ActiveRecord::Base belongs_to :question validates_presence_of :answer, :question_id end class Question < ActiveRecord::Base validates_presence_of :question has_many :answers end ############ question controller def create @question = Question.new(params[:question]) if @question.save logger.debug(@question.inspect) params[:question_answer].each_value...