Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby无法路由到站点_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails Ruby无法路由到站点

Ruby on rails Ruby无法路由到站点,ruby-on-rails,ruby,Ruby On Rails,Ruby,我尝试使用列出项目中的所有医生,但出现错误:找不到id=index51的医生 我在routes中添加了get“doctors/index51”,在doctors\u controller中有类似的内容: def index51 @doctors = Doctor.all respond_to do |format| format.html # index51.html.erb format.json { render json: @doctors }

我尝试使用
列出项目中的所有医生,但出现错误:
找不到id=index51的医生
我在routes中添加了get“doctors/index51”,在doctors\u controller中有类似的内容:

  def index51
    @doctors = Doctor.all

    respond_to do |format|
      format.html # index51.html.erb
      format.json { render json: @doctors }
    end
  end 
Routes.rb:

ZOZ::Application.routes.draw do

  resources :refferals


  resources :clinics


  resources :doctors

  get "welcome/index2"

  get "welcome/index"

  get "patients/select51"

  get "patients/show51"

  get "refferals/new"


  # The priority is based upon order of creation:
  # first created -> highest priority.

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  resources :patients

  resources :doctors do
    collection do
      get 'index51'
    end
  end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  root :to => 'welcome#index'

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id))(.:format)'
end
请帮帮我,我是Ruby的新手,我正在努力完成我的项目:)

在rake routes输出中,我有: index51(医生获取/医生/index51(:格式)医生#index51

错误:

ActiveRecord::RecordNotFound in DoctorsController#show

Couldn't find Doctor with id=index51
Rails.root: D:/Studia/Bazy Danych/Projekt/Implementacja/ZOZ

Application Trace | Framework Trace | Full Trace
app/controllers/doctors_controller.rb:25:in `show'
Request

Parameters:

{"id"=>"index51"}

也许这就是你需要的

 resources :doctors do
    collection do
      get 'index51'
    end
  end
编辑:(routes.rb发布后) 第4条评论声明

#资源:医生


它定义了两次,不是吗?

也许这就是你需要的

 resources :doctors do
    collection do
      get 'index51'
    end
  end
编辑:(routes.rb发布后) 第4条评论声明

#资源:医生


它定义了两次,不是吗?

也许这就是你需要的

 resources :doctors do
    collection do
      get 'index51'
    end
  end
编辑:(routes.rb发布后) 第4条评论声明

#资源:医生


它定义了两次,不是吗?

也许这就是你需要的

 resources :doctors do
    collection do
      get 'index51'
    end
  end
编辑:(routes.rb发布后) 第4条评论声明

#资源:医生


它定义了两次,不是吗?

这是实现你想要的最简单的方法

获取“医生/index51”至:“医生#index51”

您所做的通常是在静态页面中工作


希望对大家有所帮助

这是实现你想要的最简单的方法

获取“医生/index51”至:“医生#index51”

您所做的通常是在静态页面中工作


希望对大家有所帮助

这是实现你想要的最简单的方法

获取“医生/index51”至:“医生#index51”

您所做的通常是在静态页面中工作


希望对大家有所帮助

这是实现你想要的最简单的方法

获取“医生/index51”至:“医生#index51”

您所做的通常是在静态页面中工作


希望对大家有所帮助

刚刚查看了您的routes文件,注意到您正在使用诸如get“patients/select51”之类的路由 并获得“患者/show51”

这些路线有什么作用?选择id为51的患者并显示id为51的患者<代码>您没有创建rails RESTful路由
。你应该调查一下,以便更好地了解到底发生了什么

错误:找不到id=index51的医生
表示rails正在将index51视为id

修复:

您的routes.rb文件中有
resources:doctors
,该文件在应用程序中创建了七种不同的路由,所有路由都映射到医生控制器,如:

GET /doctors    doctors#index   display a list of all doctors
GET /doctors/new    doctors#new return an HTML form for creating a new doctor
POST  /doctors  doctors#create  create a new doctor
GET /doctors/:id    doctors#show    display a specific doctor
GET /doctors/:id/edit   doctors#edit    return an HTML form for editing a doctor
PATCH/PUT   /doctors/:id    doctors#update  update a specific doctor
DELETE  /photos/:id doctors#destroy delete a specific doctor
以下是您拥有的:

resources :doctors do
 collection do
  get 'index51'
 end
end

它正在创建一个
get/doctors/index51-doctors#index51
,并且存在冲突,因此需要删除前面的一个。尽管我仍然建议坚持默认设置,但这将要求您创建一个操作索引,而不是索引51

只是查看了您的路由文件,注意到您正在使用诸如get“patients/select51”之类的路由 并获得“患者/show51”

这些路线有什么作用?选择id为51的患者并显示id为51的患者<代码>您没有创建rails RESTful路由。你应该调查一下,以便更好地了解到底发生了什么

错误:找不到id=index51的医生
表示rails正在将index51视为id

修复:

您的routes.rb文件中有
resources:doctors
,该文件在应用程序中创建了七种不同的路由,所有路由都映射到医生控制器,如:

GET /doctors    doctors#index   display a list of all doctors
GET /doctors/new    doctors#new return an HTML form for creating a new doctor
POST  /doctors  doctors#create  create a new doctor
GET /doctors/:id    doctors#show    display a specific doctor
GET /doctors/:id/edit   doctors#edit    return an HTML form for editing a doctor
PATCH/PUT   /doctors/:id    doctors#update  update a specific doctor
DELETE  /photos/:id doctors#destroy delete a specific doctor
以下是您拥有的:

resources :doctors do
 collection do
  get 'index51'
 end
end

它正在创建一个
get/doctors/index51-doctors#index51
,并且存在冲突,因此需要删除前面的一个。尽管我仍然建议坚持默认设置,但这将要求您创建一个操作索引,而不是索引51

只是查看了您的路由文件,注意到您正在使用诸如get“patients/select51”之类的路由 并获得“患者/show51”

这些路线有什么作用?选择id为51的患者并显示id为51的患者<代码>您没有创建rails RESTful路由。你应该调查一下,以便更好地了解到底发生了什么

错误:找不到id=index51的医生
表示rails正在将index51视为id

修复:

您的routes.rb文件中有
resources:doctors
,该文件在应用程序中创建了七种不同的路由,所有路由都映射到医生控制器,如:

GET /doctors    doctors#index   display a list of all doctors
GET /doctors/new    doctors#new return an HTML form for creating a new doctor
POST  /doctors  doctors#create  create a new doctor
GET /doctors/:id    doctors#show    display a specific doctor
GET /doctors/:id/edit   doctors#edit    return an HTML form for editing a doctor
PATCH/PUT   /doctors/:id    doctors#update  update a specific doctor
DELETE  /photos/:id doctors#destroy delete a specific doctor
以下是您拥有的:

resources :doctors do
 collection do
  get 'index51'
 end
end

它正在创建一个
get/doctors/index51-doctors#index51
,并且存在冲突,因此需要删除前面的一个。尽管我仍然建议坚持默认设置,但这将要求您创建一个操作索引,而不是索引51

只是查看了您的路由文件,注意到您正在使用诸如get“patients/select51”之类的路由 并获得“患者/show51”

这些路线有什么作用?选择id为51的患者并显示id为51的患者<代码>您没有创建rails RESTful路由。你应该调查一下,以便更好地了解到底发生了什么

错误:找不到id=index51的医生
表示rails正在将index51视为id

修复:

您的routes.rb文件中有
resources:doctors
,该文件在应用程序中创建了七种不同的路由,所有路由都映射到医生控制器,如:

GET /doctors    doctors#index   display a list of all doctors
GET /doctors/new    doctors#new return an HTML form for creating a new doctor
POST  /doctors  doctors#create  create a new doctor
GET /doctors/:id    doctors#show    display a specific doctor
GET /doctors/:id/edit   doctors#edit    return an HTML form for editing a doctor
PATCH/PUT   /doctors/:id    doctors#update  update a specific doctor
DELETE  /photos/:id doctors#destroy delete a specific doctor
以下是您拥有的:

resources :doctors do
 collection do
  get 'index51'
 end
end

它正在创建一个
get/doctors/index51-doctors#index51
,并且存在冲突,因此需要删除前面的一个。尽管我仍然建议坚持默认设置,但这需要您创建一个操作索引,而不是索引51

rake routes的输出是什么??看起来您已经设置了一个成员路由,而不是收集路由。你在routes.rb有什么?Rake routes告诉我我有医生