I do not see in your code provided that your class 'Obra' Actually has a
method 'norma_legal' 

@obra.norma_legal << @norma_legal    is probably where it goes wrong.

 

Do you have more code to show how you expect this to work?

To know if the id comes through you can add some debug line to your code
(for example logger.debug( params[:norma_legal][:id])  ) before you start
using it, to see if the value comes in, which I expect it does anyway.

 

CU,


Gert

 

  _____  

From: [email protected]
[mailto:[email protected]] On Behalf
Of pamela martinez
Sent: woensdag 4 mei 2011 17:28
To: [email protected]
Subject: [rails-development] hello

 

Hi, my name is pamela and i don't know if this group is active, but i send
this mail anyway :D

 

I'm having problems with some parameters that are in another table, i mean,
in my new view i put this:

 

<p>

    <%= f.label 'Norma Legal' %><br />

    <%= select("norma_legal", "id", @norma_legal.collect {|c|
["#{c.desc_normalegal}/ #{c.nro_norma_legal}/ #{c.anio_norma_legal}",
c.id]}) %>

</p> 

 

This shows me a the data contained in the table the way i want, but in the
moment of create y get this error: undefined method `norma_legal' for
#<Obra:0xe229be>

 

Parameters: 

 
{"authenticity_token"=>"EVLBHoUoAaf8/l/oz9ftWHujKIIYfbel5mm5IzkVERI=",
 "obra"=>{"id_ejecutor"=>"1",
 "id_financ"=>"3",
 "id_dpto"=>"57",
 "nro_expte"=>"",
 "nombre_obra"=>"",
 "nro_certif_obra"=>"",
 "porc_ejec_obra"=>""},
 "norma_legal"=>{"id"=>"1"},
 "commit"=>"Create"}

 

I think that the id seems to get lost somehwere, and i don't know why, i
have this in my controller

 

def create   

    @obra = Obra.new(params[:obra])

    @norma_legal = NormaLegal.all

 

    @norma_legal = NormaLegal.find(params[:norma_legal][:id])

    @obra.norma_legal << @norma_legal

 

    respond_to do |format|

      if @obra.save

        format.html { redirect_to(@obra, :notice => 'Obra was successfully
created.') }

        format.xml  { render :xml => @obra, :status => :created, :location
=> @obra }

      else

        format.html { render :action => "new" }

        format.xml  { render :xml => @obra.errors, :status =>
:unprocessable_entity }

      end

    end

  end

 

 

Thank you very much

Pamela

-- 
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?
hl=en

-- 
You received this message because you are subscribed to the Google
Groups "ruby-on-rails-programming-with-passion" group.
To unsubscribe from this group, send email to
ruby-on-rails-programming-with-passion+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ruby-on-rails-programming-with-passion?hl=en?hl=en

Reply via email to