Hi all, I''m working on my first RoR project and it''s slowly coming together. I am having a problem getting a new object initialised from the params being sent back from the form. It goes like this... I have Questions and there are three types of questions. My questions table links to a table question_types via a foreign key in the questions table ''question_types_id'' and I''ve declared that questions belongs_to :question_type and question_type has_many :questions. So far so good, I can reference the members using dot notation fine, but the default scaff doesn''t give me a drop down list so I edited the view for the new action so it looks like this: <h1>New question</h1> <% form_tag :action => ''create'' do %> <p> <label for="question_type">Question type</label></br> <select id="question_type" name="question[question_type_id]"> <% for qt in QuestionType.find(:all) %> <option value=<%= qt.id %>><%= qt.name %></option> <% end %> </select> <%= render :partial => ''form'' %> <%= submit_tag "Create" %> <% end %> <%= link_to ''Back'', :action => ''list'' %> But when my controller tries to save it using the default static scaffold: def create @question = Question.new(params[:question]) if @question.save flash[:notice] = ''Question was successfully created.'' redirect_to :action => ''list'' else render :action => ''new'' end end it fails saying "1 error prohibited this question from being saved" I have in the question model "validates_presence_of :question_type_id" and if I remove it then it fails saying that the question_type_id cannot be null. So it seems that the question_type_id is not being set. On the lighttpd server I see the params listed correctly as I would hope. Even if I set the question_type_id like so in the controller create action: @question.question_type_id = 2 # this is a valid value then it still gives the same errors above. grr. The wierd thing is that I''m using pretty much the same code for the edit action, and that seems to work fine where the call: @question.update_attributes(params[:question]) seems to get all of the information required and updates the type id field correctly. any ideas or suggestions or pointers to stuff gratefully accepted. :) Mark -- 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 -~----------~----~----~----~------~----~------~--~---