Umm i have a problem.
my routes.rb :

map.resources :encuestas do |encuesta|
    encuesta.resources :preguntas do |pregunta|
    pregunta.resources :solucions
   end
 end

I can see perfecly the index of preguntas
Now I want to create a new pregunta.
My url->http://localhost:3000/encuestas/1/preguntas/new

In the preguntas's controller:

def index
    @encuesta = Encuesta.find(params[:encuesta_id])
    @preguntas = Pregunta.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @preguntas }
    end


In the view of new pregunta:

form_for [...@encuesta, @preguntas] do |f|
 <%= f.error_messages %>

  <p>
    <%= f.label :texto %><br />
    <%= f.text_field :texto %>
  </p>
   ...
 end

Encuesta has 2 fields, titulo and descripcion. Both are strings
Pregunta has 3 fields, encusta_id and orden are integer and text is 
string.


This is the error message:

NoMethodError in Preguntas#new

Showing app/views/preguntas/new.html.erb where line #8 raised:

undefined method `texto' for #<Encuesta:0x7ffe122c40a8>

Extracted source (around line #8):

5:
6:   <p>
7:     <%= f.label :texto %><br />
8:     <%= f.text_field :texto %>
9:   </p>
10:   <p>
11:     <%= f.label :encuesta_id %><br />



Encuesta doesn't has texto, texto is a field of preguntas. This form is 
for preguntas not for encuesta. Why is supossing that texto is a field 
of encuesta??
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to