Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:00:32+00:00 2026-06-01T10:00:32+00:00

I’ve a model named GuestOrder: class GuestOrder < ActiveRecord::Base end # == Schema Information

  • 0

I’ve a model named GuestOrder:

class GuestOrder < ActiveRecord::Base
end

# == Schema Information
#
# Table name: guest_orders
#
#  id             :integer         not null, primary key
#  notes          :string(255)
#  adults         :integer
#  children       :integer
#  created        :datetime
#  placed         :datetime
#  billed         :datetime
#  user_id        :integer
#  guest_table_id :integer
#  take_away_id   :integer
#  created_at     :datetime
#  updated_at     :datetime

And a controller

class ApiController < ApplicationController
  def getOrdersByDate
    @guest_orders = GuestOrder.where(:created_at => (params[:created]))
    render json: @guest_orders
  end
end

In routes.rb

  match '/api/getOrdersByDate'

When I try to get this in url

http://localhost:3000/api/getOrdersByDate?:created=2012-4-5

I got all the records not restricted by date

In server I got select * from guest_orders

Started GET "/api/getOrdersByDate?:created=2012-4-5" for 127.0.0.1 at 2012-04-06 13:19:59 +0530
  Processing by ApiController#getOrdersByDate as HTML
  Parameters: {":created"=>"2012-4-5"}
  GuestOrder Load (26.3ms)  SELECT "guest_orders".* FROM "guest_orders"
Completed 200 OK in 47ms (Views: 1.5ms | ActiveRecord: 26.3ms)


Started GET "/api/getOrdersByDate?:created=2012-4-5" for 127.0.0.1 at 2012-04-06 13:21:21 +0530
  Processing by ApiController#getOrdersByDate as HTML
  Parameters: {":created"=>"2012-4-5"}
  GuestOrder Load (1.7ms)  SELECT "guest_orders".* FROM "guest_orders"
Completed 200 OK in 47ms (Views: 1.4ms | ActiveRecord: 1.7ms)

Records in my DB have records in date 2012-03-22, 2012-04-05, 2012-04-06

How can I query in getOrdersByDate to get records of a particular date.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:00:33+00:00Added an answer on June 1, 2026 at 10:00 am

    You don’t need the colon in your request, HashWithIndifferentAccess wiill do the sym lookup for you.

    http://localhost:3000/api/getOrdersByDate?created=2012-4-5
    

    But the problem looks interesting, because passing a nil to a where conditions should cause the following query:

    SELECT "guest_orders".* FROM "guest_orders" WHERE "created_at" IS NULL
    

    And in your case the whole SQL WHERE condition is missing.

    Update #1

    Seems like reloading needed.

    To fetch the records for a date you could use the following method:

    time = Time.zone.parse(params[:created])
    range = time.beginning_of_day..time.end_of_day
    @guest_orders = GuestOrder.where(:created_at => range)
    

    Update #2

    If you have a start and an end date:

    t_start = Time.zone.parse(params[:start])
    t_end = Time.zone.parse(params[:end])
    range = t_start.beginning_of_day..t_end.end_of_day
    @guest_orders = GuestOrder.where(:created_at => range)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.