Hi,
I have a Model for my_table table
which serialises a column named serialised_column
serialised_column contains an array object, which contains hash objects
something like
serialised_column = [{''name'' => ''this''},
{''name'' => ''that''}]
the code for model is something like this
class MyTable < ActiveRecord::Base
set_table_name ''my_table''
serialize :serialised_column
end
and a controller which access the data
class ShowController < ApplicationController
def show
s = MyTable.find(:all, :conditions => [''some
conditions''])
if s.size != 0
@s = []
s.serialised_column.each { |s|
@s << [''name'' => s[''name'']]
}
end #if
end #def
end #class
in view the show.rhtml file is something like
<%# considering size of s is not zero
%>
<%= @s[0][''name''] %>
now when I run this file, I get an TypeError exception, which says
''can''t
convert String into Integer''
why is so? I''m not casting a string to intger, and neither want it to
happen!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
you''re pushing arrays onto @s: @s << [''name''
=> s[''name'']]
with your current structure you''d have to access them like
@s[0][0][''name]
maybe instead you can just push hashes: @s << {''name''
=> s[''name'']}
On Oct 13, 10:44 pm, "Vikrant Chaudhary"
<nas...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hi,
> I have a Model for my_table table
> which serialises a column named serialised_column
> serialised_column contains an array object, which contains hash objects
> something like
> serialised_column = [{''name'' =>
''this''}, {''name'' =>
''that''}]
>
> the code for model is something like this
>
> class MyTable < ActiveRecord::Base
> set_table_name ''my_table''
> serialize :serialised_column
> end
>
> and a controller which access the data
> class ShowController < ApplicationController
> def show
> s = MyTable.find(:all, :conditions => [''some
conditions''])
> if s.size != 0
> @s = []
> s.serialised_column.each { |s|
> @s << [''name'' => s[''name'']]}
>
> end #if
> end #def
> end #class
>
> in view the show.rhtml file is something like
> <%# considering size of s is not zero
> %>
> <%= @s[0][''name''] %>
>
> now when I run this file, I get an TypeError exception, which says
''can''t
> convert String into Integer''
> why is so? I''m not casting a string to intger, and neither want it
to
> happen!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Thanks, I got it. Its working now. thanks again. On Oct 14, 8:04 am, jemminger <jemmin...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you''re pushing arrays onto @s: @s << [''name'' => s[''name'']] > > with your current structure you''d have to access them like > @s[0][0][''name] > > maybe instead you can just push hashes: @s << {''name'' => s[''name'']} > > On Oct 13, 10:44 pm, "Vikrant Chaudhary" <nas...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > I have a Model for my_table table > > which serialises a column named serialised_column > > serialised_column contains an array object, which contains hash objects > > something like > > serialised_column = [{''name'' => ''this''}, {''name'' => ''that''}] > > > the code for model is something like this > > > class MyTable < ActiveRecord::Base > > set_table_name ''my_table'' > > serialize :serialised_column > > end > > > and a controller which access the data > > class ShowController < ApplicationController > > def show > > s = MyTable.find(:all, :conditions => [''some conditions'']) > > if s.size != 0 > > @s = [] > > s.serialised_column.each { |s| > > @s << [''name'' => s[''name'']]} > > > end #if > > end #def > > end #class > > > in view the show.rhtml file is something like > > <%# considering size of s is not zero > > %> > > <%= @s[0][''name''] %> > > > now when I run this file, I get an TypeError exception, which says ''can''t > > convert String into Integer'' > > why is so? I''m not casting a string to intger, and neither want it to > > happen!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---