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
我想链接一个按钮来修改我的钱包用户,原理是用一个简单的按钮在我的用户的钱包上添加钱。别忘了,只使用资源是可行的。
我的选项卡用户
ID | 电子邮件 | ENCRYPTED_PASSWORDRESET_PASSWORD_TOKENRESET_PASSWORD_SENT_EMEMBER_CREATED_ATCREATED_AT | ADMIN | WALLET | ||||
---|---|---|---|---|---|---|---|---|
9 | rolf@kassulke-rohan.biz | $2a$12$xpCaMAWCDqDm7QrLR98z | 2021-03-13 17:32:59 | 2021:03-13 17:34:59 | false | |||
10 | malcolm@smith.net | $2a$12$SBk4Ok4qtdresgA。V7KP | 2021-03-13 17:33:00 | |||||
11 | raymond@langosh.info | $2a$12$5mRP2WCS98Pa.2DF0dO…… | 2021-03-13 17:33:01 | <21-03-13>false | ||||
12 | edwin@padberg.net | $2a$12$hUBW4ZZBUPGN06jOlV37… | 2021-03-13 17:33:02 | 2021-03-1 17:33:02错误|||||
13 | setsuko@feeney.info | $2a$12$5hIY76sZyjp3GFgxX.6I… | 2021-03-13 17:33:02 | 2021:03-13 17:33:02false | ||||
8 | ai@wiegand.org | $2a$12$XD.3sehDXE0WCVavfWDY… | 2021-03-13 17:32:58 | 2021-03-1 17:36:50 | 错误0||||
14 | back-phonix@lie.fr | $2a$12$Iia9pUpGDJPCeuYTUvAk | 2021-03-13 17:38:10 | 2021:03-13 23:15:25 | 真<1042>
您可以将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