So I got:

NoMethodError in GazetteController#show_article

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.+


The controller action:

def show_article

@gazette = Gazette.bydate('2006', '06', '04')

render(:layout => 'interior', :template => 'index')

The model method:

def self.bydate(year, month, day)

d = @year + '-' + @month + '-' + @day

n = find_by_sql("select id, published, date_format(published, '%M %D, %Y') as d, headline, body " +
			"from gazettes where published='#{d}' " +
			"order by d desc limit 1")

return n[0]

That SQL should return a record with the given test inputs.

Now I'm not sure how to troubleshoot this... it's not really giving me much to go on.

Is there any way to get it to output the SQL it actually uses? I'm so used to PHP, building my own queries, and being able to do a quick echo "<p>$query</p>" in the code.

BTW, any easier way to find by date with RoR?