【发布时间】:2017-10-19 07:50:36
【问题描述】:
经过身份验证的用户应该能够通过其仪表板的表单添加钱包地址。在我的路线中
scope '/dashboard', module: :dashboard do
get '/', to: 'dashboard#index', as: '/dashboard'
post '/eth_address', to: 'dashboard#eth_address'
end
我的表格
<%= form_for eth_address_path do |f| %>
<%= f.label :eth_address %>
<%= f.text_field :eth_address %>
<%= f.submit "Save" %>
<% end %>
在views/dashboard/dashboard/index.html.erb中
还有我的简单控制器
Dashboard::DashboardController
在
controllers/dashboard/dashboard_controller.rb
用方法
def eth_address
eth_addr = params[:eth_address]
EthereumWallet.create(user_id: current_user.id,
address: eth_addr)
end
仪表板的轨道路线
dashboard GET /dashboard(.:format) dashboard/dashboard#index
eth_address POST /dashboard/eth_address(.:format) dashboard/dashboard#eth_address
提交后我看到了这个:
No route matches [POST] "/dashboard"
我不知道为什么它要求我从 /dashboard 发出 POST 请求。
谢谢
【问题讨论】:
-
显示您的路线。耙路线
-
添加了提问的路线
-
form_for :eth_address_path
标签: ruby-on-rails ruby routing