On Oct 1, 3:50 am, Bala <mbbala-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello Experts,
>
> When i try to use json converstion for Array it works perfectly in
> local machine,
>
> But when i deployed to server it says this error message which i
> detected on firebug
>
> I''ve two datas on DB
> Model - Codes
>
> Codes
> 1 - First
> 2 - Second
> 3 - Third
>
> Here I have a code like this
> Controller
> name = "%#{params[:id]}%"
> @codes = Code.find(:all, :condition => ["name like ?", name])
>
> on View
>
> <input type="text" id="input_id">
> <a href="javascript:void(0);"
>
onclick="filter_this(document.getElementById(''input_id''),
<
> %=-0+Z/LtoomSM@public.gmane.org_json%>);">Click Me</a>
>
> and javascript code
> function filter_this(myInput, codes) {
> for(var i=0;i<codes.length;i++) {
> var myid = codes[i].attributes;
> var filter_divs = ''div'' + myid.id;
> document.getElementById(filter_divs);
> }
>
> }
>
> This code works perfectly in local but in server it says myid has no
> properties.
>
I suggest you examine the generated JSON. Firebug also has a
javascript debugger you can see what is going on (I suspect the
problem is that codes[i] does not have an attributes property. The
difference is probably that in production you have a newer version of
rails than in development - newer versions of rails add a to_json
method to activerecord objects that just dump the attributes)
Fred
> NOTE: I''ve included all necessary javascript codes.
>
> Thanks in advance
> Bala
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---