query not displaying proper result
- by ravindra
In my Rails 3 project I have the following code for
My controller:
class TasksController < ApplicationController
def today
@tasks = Task.today
@task = Task.new
respond_to do |format|
format.html { render :text=> "Sorry , you don't have any task pending today." }
format.html # new.html.erb
format.xml { render :xml => @tasks }
end
end
def this_week
@tasks = Task.this_week
@task = Task.new
respond_to do |format|
format.html { render :text => "Sorry , No content for selected period." }
format.html # new.html.erb
format.xml { render :xml => @tasks }
end
end
end
My model:
class Task < ActiveRecord::Base
def self.today
Task.where(:due_date => "Date.today" , :task_status => "open").order("due_date ASC")
end
def self.this_week
Task.where(:due_date =>"Time.now.this_week" , :task_status => "open" ).order("due_date ASC")
end
end
Why it does not displaying anything in the relative view. Please help me.
Thanks