ruby rails
2012-Oct-30 07:15 UTC
pass javascript date variable to rails controller as params
I have an application where jquery fullcalendar is implemented. On day click I need to pass the selected date as params to rails controller. When I alert the date inside dayclick function, I am getting the date in the format of "Tue Oct 30 2012 12:40:20 GMT+0530 (IST)".. But when I pass as params in jquery ajax to rails controller, it is passing blank. How do I get it in rails controller successfully. Please find my code for dayclick below. dayClick: function(date, allDay, jsEvent, view) { var date = $(''#calendar'').fullCalendar(''getDate''); alert(date); $.get("<%=update_projects_admins_users_path%>", { id:''<%=params[:user]%>'', date_selected: date.getDate() }, function(data) { $(''.active_projects'').html(data); //alert("Data: " + data + "\nStatus: " + status); } ); if (allDay) { alert(''Clicked on the entire day: '' + date); } } -- 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.
Luis Vasconcellos
2012-Oct-30 07:49 UTC
Re: pass javascript date variable to rails controller as params
I don''t see any problems with your jQuery code. Are you sure you are using the correct route ? If you are sending this form to a default update rails action, the path correct path is not that one. * Luis Va**sconcellos *|* *Web Developer at DTM wblog: luisvasconcellos.com twitter: @vasconcelloslf <http://www.twitter.com/vasconcelloslf> mobile: 55 21 95100576 http://dtmtec.com.br <http://www.dtmtec.com.br> @dtmtec <http://www.twitter.com/dtmtec> 2012/10/30 ruby rails <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>> I have an application where jquery fullcalendar is implemented. On day > click I need to pass the selected date as params to rails controller. > When I alert the date inside dayclick function, I am getting the date in > the format of "Tue Oct 30 2012 12:40:20 GMT+0530 (IST)".. But when I > pass as params in jquery ajax to rails controller, it is passing blank. > How do I get it in rails controller successfully. Please find my code > for dayclick below. > > > > dayClick: function(date, allDay, jsEvent, view) { > var date = $(''#calendar'').fullCalendar(''getDate''); > alert(date); > $.get("<%=update_projects_admins_users_path%>", > { > id:''<%=params[:user]%>'', > date_selected: date.getDate() > }, > function(data) > { $(''.active_projects'').html(data); > //alert("Data: " + data + "\nStatus: " + > status); > } > ); > if (allDay) { > alert(''Clicked on the entire day: '' + date); > } > } > > -- > 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.