I am having trouble getting form_for to use method :put for my edit
view which has been driving me crazy. in the controller i have
User.find, not User.new so i can’t figure out why this always
generates a method post.
i have tried the following and they all generate method = post, even
when i specify :method => :put!!!
<% form_for(:user) do |f| %>
<% form_for(:user, @user) do |f| %>
<% form_for(:user, @user, :url => admin_site_user_path ) do |f| %>
<% form_for :user, @usert, :url => admin_site_user_path, :html =>
{ :method => :put, :class => “edit_post”, :id => “edit_post_14” } do |
f| %>
<% form_for(:user, :url => admin_site_user_path, :method => :put ) do
|f| %>
digging through rails i found form_helper.rb with
apply_form_for_options! which looks like where rails decides if it
should be a put or post and to where.
def apply_form_for_options!(object_or_array, options) #:nodoc:
......
html_options =
if object.respond_to?(:new_record?) && object.new_record?
{ :class => dom_class(object, :new), :id =>
dom_id(object), :method => :post }
else
{ :class => dom_class(object, :edit), :id =>
dom_id(object, :edit), :method => :put }
end
…
. end
there is the “if object.respond_to?(:new_record?) &&
object.new_record?” so i added that to my view and that detects things
correctly, but the form still is a post???
see my code below and HOPEFULLY tell me what i am doing wrong
i have a User model created by restful_authentication
controller
class Admin::SiteUsersController < ApplicationController
before_filter :login_required
require_role :admin
def edit
@user = User.find(params[:id])
render :layout => false
end
end
edit view
<%= error_messages_for :user %>