undefined method `belogns_to'
I have some code in view:
<%= form_for(:report_main, :url => {:action => 'exporttoxiccreate'}) do |f| %>
<%= select_tag('vrstaotpada',options_for_select([['Komercijalni otpad', 'Komercijalni otpad'], ['Industrijski otpad', 'Industrijski otpad']])) %>
<%= collection_select(:waste, :code, Waste.find_all_by_istoxic(false), :id, :code, :include_blank => '') 开发者_C百科%>
<%= f.check_box(:q_pripadnost) %>
<%= f.text_field(:amount) %>
<%= select_tag('nacinpakovanja',options_for_select([['Drveno bure', 'Drveno bure'], ['Kanister', 'Kanister'], ['Sanduk', 'Sanduk'], ['Kese', 'Kese'], ['Posude pod pritiskom', 'Posude pod pritiskom'], ['Kompozitno pakovanje', 'Kompozitno pakovanje'], ['Rasuto', 'Rasuto'], ['Ostalo', 'Ostalo']])) %>
<%= f.text_field(:ispitivanjebroj) %>
<%= f.text_field(:datumispitivanja) %>
<% end %>
and this in controller "report_main":
def exporttoxiccreate
@report = ReportMain.new
@reportexport = ReportExport.new
@reportparam = params[:report_main]
@report.waste_id = @reportparam.waste.code
@report.warehouse_id = 1
@report.user_id = 1
@report.company_id = 1
@report.amount = @reportparam.amount
@report.isimport = false
@report.isfinished = false
if @report.save
@reportexport.report_main_id = @report.id
else
redirect_to(:action => 'exporttoxicnew')
end
@reportexport.vrstaotpada = @reportparam.vrstaotpada
@reportexport.nacinpakovanja = @reportparam.nacinpakovanja
@reportexport.ispitivanjebroj = @reportparam.ispitivanjebroj
@reportexport.datumispitivanja = @reportparam.datumispitivanja
@reportexport.q_pripadnost = @reportparam.q_pripadnost
if @reportexport.save
redirect_to(:action => 'show', :id => @reportexport.id)
else
redirect_to(:action => 'exporttoxicnew')
end
end
And when I submit the form I got strange error:
undefined method `belogns_to' for
Why I need belongs_to method? What goes there?
Sounds like you're trying to create an active record assocation of belongs_to
but mispelled it to belogns_to
. So go check your model.
精彩评论