arturo drlt
2012-Aug-16 18:20 UTC
undefined method `with_indifferent_access'' for "":String
Hi
I''m having a issue with one object when try to update the attributes in
this object previously saved in the database
I have one object comp and one object reg they have this relationship
comp
has_many regs
reg
belongs_to comp
when run use the method valid? like this
current_contribuyente.comps.build(params[:comp]).valid?
it returns: IndexError (string not matched)
And when I try to update directly the comp directly it return this
error:
@comp = current_contribuyente.comps.find(params[:id])
@comp.update_attributes(params[:comp])
NoMethodError (undefined method `with_indifferent_access'' for
"":String):
This is the code from the view where I create this elements
= form_for @comp, :html => {:id => "new_form", :onsubmit =>
"return
validate_form()"}, :remote => true do |f|
= f.fields_for :comprobante_emis_regs_attributes do |cer|
= cer.collection_select :reg_fil,
current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil,
{:include_blank => false}, :class => ''reg_fil'', :name
=>
"comp[comp_emis_regs_attributes][0][reg_fil]"
Somebody has run into this issue i''m really running out of ideas of how
to fix this.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2012-Aug-16 20:38 UTC
Re: undefined method `with_indifferent_access'' for "":String
On 16 August 2012 19:20, arturo drlt <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi > > I''m having a issue with one object when try to update the attributes in > this object previously saved in the database > > I have one object comp and one object reg they have this relationship > > comp > > has_many regs > > reg > > belongs_to comp > > when run use the method valid? like this > > current_contribuyente.comps.build(params[:comp]).valid?What is current_contribuyente? Colin> > it returns: IndexError (string not matched) > > And when I try to update directly the comp directly it return this > error: > @comp = current_contribuyente.comps.find(params[:id]) > > @comp.update_attributes(params[:comp]) > > NoMethodError (undefined method `with_indifferent_access'' for > "":String): > > > This is the code from the view where I create this elements > > = form_for @comp, :html => {:id => "new_form", :onsubmit => "return > validate_form()"}, :remote => true do |f| > > = f.fields_for :comprobante_emis_regs_attributes do |cer| > = cer.collection_select :reg_fil, > current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil, > {:include_blank => false}, :class => ''reg_fil'', :name => > "comp[comp_emis_regs_attributes][0][reg_fil]" > > > Somebody has run into this issue i''m really running out of ideas of how > to fix this. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
arturo drlt
2012-Aug-16 20:48 UTC
Re: undefined method `with_indifferent_access'' for "":String
Colin Law wrote in post #1072606:> On 16 August 2012 19:20, arturo drlt <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > What is current_contribuyente? > > Colincurrent_contribuyente is a method that works similar to current_user work like these: def current_contribuyente current_user.contribuyente end it just a custom current_user that retrieves a model (contribuyente) for the current_user contribuente has_many :comps -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Peter p.
2012-Aug-17 11:34 UTC
Re: undefined method `with_indifferent_access'' for "":String
arturo drlt wrote in post #1072587:> Hi > > I''m having a issue with one object when try to update the attributes in > this object previously saved in the database > > I have one object comp and one object reg they have this relationship > > comp > > has_many regs > > reg > > belongs_to comp > > when run use the method valid? like this > > current_contribuyente.comps.build(params[:comp]).valid? > > it returns: IndexError (string not matched) > > And when I try to update directly the comp directly it return this > error: > @comp = current_contribuyente.comps.find(params[:id]) > > @comp.update_attributes(params[:comp]) > > NoMethodError (undefined method `with_indifferent_access'' for > "":String): > > > This is the code from the view where I create this elements > > = form_for @comp, :html => {:id => "new_form", :onsubmit => "return > validate_form()"}, :remote => true do |f| > > = f.fields_for :comprobante_emis_regs_attributes do |cer| > = cer.collection_select :reg_fil, > current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil, > {:include_blank => false}, :class => ''reg_fil'', :name => > "comp[comp_emis_regs_attributes][0][reg_fil]" > > > Somebody has run into this issue i''m really running out of ideas of how > to fix this.******************************************************************** Hi arturo drlt, Try without "fields_for" It really works! ;-) Regards, Peter ****************************************************************** -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
arturo drlt
2012-Aug-17 19:25 UTC
Re: undefined method `with_indifferent_access'' for "":String
Peter p. wrote in post #1072655:> arturo drlt wrote in post #1072587:> > > ******************************************************************** > Hi arturo drlt, > > Try without "fields_for" > It really works! ;-) > > Regards, > Peter > ******************************************************************I always had troubles writing the code for this model using only collection_select so far i have this code: - if comp_exist = collection_select(:comp, :comp_emis_regs_reg_fil, current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil, {:include_blank => false}) - else = collection_select(:contribuyente, :contribuyente_regs_reg_fil, current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil, {:include_blank => false}, {:class => ''reg_fil'', :name => "comp[comp_emis_regs_attributes][0][reg_fil]"}) and the first collection_select return this error undefined method `comp_emis_regs[0].reg_fil'' for #<Comp:0x7f90f655ca38> because the method :comp_emis_regs_reg_fil its really one array and i don''t know how to specify the method for the reg_fil attribute inside :comp_emis_regs because the relationship is has_many, some ideas? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
arturo drlt
2012-Aug-17 21:31 UTC
Re: undefined method `with_indifferent_access'' for "":String
Sorry i wrote a wrong error the collection_select return this error
undefined method `comprobante_emis_regs_reg_fil'' for
#<Comp:0x7f90f6298ae0>
collection_select(:comp, :comp_emis_regs_regimen_fiscal,
current_contribuyente.contribuyente_regs, :reg_fil, :reg_fil,
{:include_blank => false})
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
arturo drlt
2012-Aug-17 23:18 UTC
Re: undefined method `with_indifferent_access'' for "":String
UPDATE
code:
collection_select(:comp, :comp_emi_reg_ids, CompEmiReg.where("comp_id =
?", @comp.id), :id, :reg_fil, {:include_blank => false})
return this error
NoMethodError (undefined method `with_indifferent_access'' for
"":String):
and this code:
collection_select(:comp, :comp_emi_reg_ids, CompEmiReg.where("comp_id =
?", @comp.id), :reg_fil, :regi_fil, {:include_blank => false})
return this error:
ActiveRecord::RecordNotFound (Couldn''t find CompEmiReg with ID=0):
I tried to do this
collection_select(:comp, :comp_emi_reg_regs_fils,
CompEmiReg.where("comp_id = ?", @comp.id), :reg_fil, :regi_fil,
{:include_blank => false})
but it don''t wokrs it returns:
NoMethodError: undefined method `comp_emi_reg_regs_fils'' for
#<Comp:0x7ffd398b58d8>
it seems that in the param of method for collection I only can send the
attribute id in plural other fields just return NoMethodError, I don''t
know what I''m doing wrong at the end always end up with NoMethodError
(undefined method `with_indifferent_access'' for "":String):
somebody knows another way to do this or knows if in the param method it
only can receive ids for this kind of relationship?
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.