Ruby on Rails Wednesday, September 26, 2012

On Sep 26, 2012, at 5:00 AM, ruby rails wrote:

> I am trying to integrate the arshaw's jqurey fullcalendar into my rails
> application. When I click on the calendar tab it should display the
> calendar with the list of tasks in the database on the corresponding
> date.
>
> In Calender Controller
>
> def index
>
> @task=Task.find_all_by_pm_id(params[:u])
> @task.each do |t|
> @task_name=t.task_name
> @end_date=t.due_date

Right here, you are looping over the tasks and assigning them (one after another) to the same variable. You're overwriting the singular variable each time, which is why you end up with only one (the last) task.

Not sure how your view wants to get these, but I would put them in a hash or an array for transport to the view.

> end
> end
>
> In the Calenders/index.html.erb
>
> <script>
> $(document).ready(function() {
> var date = new Date();
> var d = <%=@end_date.day%>;
> var m = <%=@end_date.month%>-1;
> var y = <%=@end_date.year%>;
> var calendar = $('#calender').fullCalendar({
> header: {
> left: 'prev,next today',
> center: 'title',
> right: 'month,agendaWeek,agendaDay'
> },
> selectable: true,
> selectHelper: true,
> events: [
> {
> title: '<%=@task_name%>',
> start: new Date(y, m, d)
> },
>
> ],
> editable: true
>
> });
>
> });
>
> </script>
>
> Now it is displaying only the last task name. I need to display all the
> task name on particular dates. Any inputs on this will be appreciated.
> Please help

HTH,

Walter

>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> 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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment