Я хотел запрашивать данные, используя между пунктом как этотКак запрашивать данные с помощью рельсов?
select * from timerecords where empid=? and date between ? and ?
Я просто должны это сделать в рельсах. У меня есть этот код, и я хочу, чтобы программа отображалась в json-формате, перенаправляя на localhost/timerecords.
def showtimerecords
empid=params[:empid]
startdate=params[:date]
enddate =params[:date]
render json: @timerecords=Timerecords.where(empid: empid,
:date => startdate..enddate)
#redirect_to @timerecords
end
Когда я печатаю http://localhost:3000/timerecords/showtimerecords/empid=2&startdate=2015-03-26&enddate=2015-03-27
Он говорит,
(No route matches [GET] "/timerecords/showtimerecords/empid=2&startdate=2015-03-26&enddate=2015-03-27")
Вот мой конфиг/route.rb код
Rails.application.routes.draw do
get 'timerecords/showtimerecords'
get 'timerecords/index'
get 'employees/index'
get 'employees/show'
get 'employees/new'
get 'welcome/index'
root :to => 'employees#new'
resources :timerecords, :employees
post 'employees/update_info'
post 'timerecords/update_time'
end
Пожалуйста, добавьте * конфиг/routes.rb * –
Вы можете разместить ссылку, которую вы используете здесь – RSB