I have a jquery date selector in my view that sends the :start_date and :end_date into my model which successfully creates an entry in my queries model which has attributes start_date and end_date.
In my controller I have a line in a mySQL query that takes string variables query.start_date and query.end_date. Those successfully pull from the model if I hand-define the start_date and end_date methods with individual dates.
In my controller, I also have query = Query.new to instantiate a class.
Finally, here is the code in my model, with my main page reloading on successful entry of a date range (which should then generate a graph with said date range):
class Query < ActiveRecord::Base
attr_accessible :name, :created_at, :start_date, :end_date
validates_presence_of :start_date, :end_date
def start_date
start_date = Query.last.start_date
end
def end_date
end_date = Query.last.end_date
end
Currently, I’m getting an error undefined methodlast’ for ActiveRecord::AttributeMethods::Query:Module`
I’m a bit confused about how to grab that last entry and have my page reload to display those date values.
Try
Query.all.last.end_dateorQuery.find(:all).last.end_dateEdit