Ruby on Rails Saturday, July 30, 2011

On Jul 30, 3:57 am, jdkealy <jdke...@gmail.com> wrote:

>
> A date looks like Fri Jul 29 2011 22:54:08 GMT-0400 (EDT)
>
> When i select from my events table i run:
> @member_calendars = Member::Calendar.find_by_sql("SELECT * from
> calendars")
> @json_calendar = ActiveSupport::JSON.encode(@member_calendars)
>
> How can i get my dates into a format that works for this json object?

Looks like that calendar plugin would be happy with iso8601 dates,
which is what rails should generate by default when encoding dates as
json
>
> Also, how would i pull my json object into the view so i can play with
> it in javascript.
>
> The following code treats my json object as a string:
>
>               var foo = '<%= @json_calendar %>';

You asked for it to be a string - you've enclosed it in quotes

Fred
>                 $.each(foo, function(i, item) {
>                         alert(i);
>                 });
>
> It will alert each and every character from my object

--
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@googlegroups.com.
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.

No comments:

Post a Comment