Re: CURDATE()
Btw, to read on further on named_scope, or other ways to get the same records without resorting to a raw sql, check out http://apidock.com/rails. Then go to the documentations of named_scope, ActiveRecord::Base, and ActiveRecord's find method by typing "named_scope", "Base" and "find" in the search box and wait for the ajax part to show the links to the actual pages. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to heroku@googlegroups.com To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~--~~~~--~~--~--~---
Re: CURDATE()
CURDATE is a MySQL function. Heroku uses PostgreSQL whose current date function is CURRENT_DATE. In Rails, it's not recommended to use raw SQL if possible. This way, it doesn't matter what database you are using, it just works. For example, in your case, you can add a named scope to your Announcement model: named_scope :active, :conditions => [ "expires_on > ?", Date.today], :limit => 2 Something like that. Then you can just call Announcement.active and it will return 2 announcements with expires_on after today. Actually, I'm kinda concerned that you have 2 columns for the announcement to determine if its active or not. I mean is it possible to have active column to be true but expires_on to be before the current date? Why not just use expires_on? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to heroku@googlegroups.com To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~--~~~~--~~--~--~---
Re: CURDATE()
here is the error: PGError: ERROR: function curdate() does not exist LINE 1: ...nouncements" WHERE (active = 't' and expires_on > CURDATE ())... ^ HINT: No function matches the given name and argument types. You may need to add explicit type casts. : SELECT count(*) AS count_all FROM "announcements" WHERE (active = 't' and expires_on > CURDATE()) LIMIT 2 Extracted source (around line #3): 1: 2: 3: <% if @announcements.empty? %> 4: There are no new announcements. 5: <% else %> 6: the model contains the function curdate, it doesn't recognize it for some reason. On Dec 24, 8:05 pm, mikong wrote: > Can you advise where you are running this and the command you are > running? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to heroku@googlegroups.com To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~--~~~~--~~--~--~---
Re: CURDATE()
Can you advise where you are running this and the command you are running? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to heroku@googlegroups.com To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~--~~~~--~~--~--~---
CURDATE()
Heroku isn't recognizing the curdate() function and says I have to type cast it. What should I do?? Thanks, Jerm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to heroku@googlegroups.com To unsubscribe from this group, send email to heroku+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~--~~~~--~~--~--~---