开发者

Calling controller's update on a custom form in rails 3

开发者 https://www.devze.com 2023-03-07 10:07 出处:网络
I have a开发者_运维知识库 custom edit.html.erb form and I would like to it to call controller\'s update

I have a开发者_运维知识库 custom edit.html.erb form and I would like to it to call controller's update

This is the code I'm using for form

<%= form_tag('/schedules/1', :class => "edit_schedule") do %>

I'm getting "No route matches "/schedules/1" error.


Try this:

In controller edit action

def edit
  @schedule = Schedule.find(1)
end

In view edit.html.erb

<%= form_tag(@schedule, :class => "edit_schedule", :method => :put) do %>

In routes.rb

resources :schedules
0

精彩评论

暂无评论...
验证码 换一张
取 消