Ruby on rails 如何在Rails中为控制器添加命名帮助器

Ruby on rails 如何在Rails中为控制器添加命名帮助器,ruby-on-rails,ruby,ruby-on-rails-4,model-view-controller,controller,Ruby On Rails,Ruby,Ruby On Rails 4,Model View Controller,Controller,以下是我的应用程序中的路线: user@localhost:~/HelloWorld$ rake routes Prefix Verb URI Pattern Controller#Action biodata_store GET /biodata/store(.:format) biodata#store greet_welcome GET /greet/welcome(.:format) greet#welcome greet_wishes GE

以下是我的应用程序中的路线:

user@localhost:~/HelloWorld$ rake routes
       Prefix Verb URI Pattern              Controller#Action
biodata_store GET  /biodata/store(.:format) biodata#store
greet_welcome GET  /greet/welcome(.:format) greet#welcome
 greet_wishes GET  /greet/wishes(.:format)  greet#wishes
   time_htime GET  /time/htime(.:format)    time#htime
   login_auth POST /login/auth(.:format)    login#auth
              POST /biodata/store(.:format) biodata#store
        greet GET  /greet(.:format)         greet#index
         time GET  /time(.:format)          time#index
        login GET  /login(.:format)         login#index
      biodata GET  /biodata(.:format)       biodata#index
user@localhost:~/HelloWorld$ 
在上面的路由中,我有一个名为“login”的控制器。因此,当我调用'localhost:3000/login'时,它会提供'index.html'文件 位于“app/view/login/”目录中。一旦我提交了登录表单,输入的数据将进入'/login/auth'操作。我在这里 将方法设置为index.html文件中的POST。所以,我只能直接从浏览器中获取“/login”而不是“/login/auth”页面

与此类似,我创建了一个“/biodata”控制器,它提供输入表单以从用户处获取详细信息。一旦我提交了表格 使用POST方法将数据传递到“/biodata/store”。因此,我希望我不能直接从中访问“/biodata/store”控制器 浏览器但在我的应用程序中,我可以访问它。如何解决这个问题

    /login --> User can access directly.
    /login/auth --> User should not access this page directly.
如上所述,登录控制器工作正常。但是下面的biodata控制器工作不正常

    /biodata --> User can access directly.
    /biodata/store --> User should not access this page directly.(But now it is accessible). 
我想这是由于指定的助手。因为控制器/biodata/store的命名帮助器中没有条目。那么如何解决这个问题呢

routes.rb:

Rails.application.routes.draw do
  get 'biodata/store'
  get 'greet/welcome'
  get 'greet/wishes'
  get 'time/htime'
  post 'login/auth'
  post 'biodata/store'
  get 'greet' => 'greet#index'
  get 'time' => 'time#index'
  get 'login' => 'login#index'
  get 'biodata' => 'biodata#index'
end

用户可以直接访问此页面,因为您有

get 'biodata/store'

在routes.rb中选择路线。只要删除它,您就可以开始了

您可以发送路由文件吗?只需删除GET/biodata即可/store@TonyVincent谢谢你的帮助。我忘了看那个。