rails 5x问题可以添加没有crud的路线吗



Hello for begin对我来说不可能在我的路由中添加一些东西。rb

利用资源是可能的。

我的路线.rb

Rails.application.routes.draw do
root 'pages#home'
devise_for :users
resources :faucets
resources :posts
resources :users
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

end

我想链接一个按钮来修改我的钱包用户,原理是用一个简单的按钮在我的用户的钱包上添加钱。别忘了,只使用资源是可行的。

我的选项卡用户

ENCRYPTED_PASSWORDRESET_PASSWORD_TOKENRESET_PASSWORD_SENT_EMEMBER_CREATED_AT<21-03-13>2021-03-1 17:33:02错误2021:03-13 17:33:02错误0真<1042>
ID电子邮件CREATED_ATADMINWALLET
9rolf@kassulke-rohan.biz$2a$12$xpCaMAWCDqDm7QrLR98z2021-03-13 17:32:592021:03-13 17:34:59false
10malcolm@smith.net$2a$12$SBk4Ok4qtdresgA。V7KP2021-03-13 17:33:00
11raymond@langosh.info$2a$12$5mRP2WCS98Pa.2DF0dO……2021-03-13 17:33:01false
12edwin@padberg.net$2a$12$hUBW4ZZBUPGN06jOlV37…2021-03-13 17:33:02
13setsuko@feeney.info$2a$12$5hIY76sZyjp3GFgxX.6I…2021-03-13 17:33:02false
8ai@wiegand.org$2a$12$XD.3sehDXE0WCVavfWDY…2021-03-13 17:32:582021-03-1 17:36:50
14back-phonix@lie.fr$2a$12$Iia9pUpGDJPCeuYTUvAk2021-03-13 17:38:102021:03-13 23:15:25

您可以将faucet方法作为集合添加到faucets资源:

# routes.rb
resources :faucets do
collection do
post :faucet
end
end

有了这个,你的按钮就会工作,但你必须将link_to调整为faucet_faucets_path

最后我使用了这个:

resources :faucets do
collection do
patch :faucet
end
end

最新更新