我是Ruby on Rails的新手, 我想制作一个简单的文本字段,您可以在其中更改内容并将其存储在数据库中。但提交按钮不会调用配置文件控制器。 “Foo”从未被提出。Ruby on rails提交按钮不会调用控制器
的routes.rb:
Rails.application.routes.draw do
devise_for :users
get 'welcome/user'
resources :profiles
end
user.html.erb:
...
<%@profile=Profile.find_by user_id: current_user.id%>
<%= form_for (@profile) do |f| %>
<%= f.text_field :name%>
<%= f.submit%>
<% end %>
profiles_controller.rb:
class ProfilesController < ActionController::Base
def update
raise "foo"
end
end
看看你的服务器,看看是什么动作叫做 – Ursus
'<%@ profile = Profile.find_by user_id:current_user.id%>' - 那东西绝对属于控制器。 –
也许你需要为'form_for'帮手提供动作。 –