這是我和remote_form_tag使用:爲什麼我的remote_form_tag with:action定義不發佈操作?
<% form_remote_tag(:url => {:controller => '/companies', :action => 'update'},
:update => 'tags') do %>
<%= text_field :company, :tag_list %>
<%= submit_tag 'Save' %>
<% end %>
這是在Company.view,其中公司是acts_as_taggable_on啓用的典範。
我的期望是,通過AJAX,一個崗位就是企業/ 10 /更新
但是做,反而什麼是貼的是:
http://localhost:3000/companies/10
和反應是:
No action responded to 10. Actions: create, destroy, edit, email_this_week, index, new, show, and update
這是CompaniesController的更新方法:
def update
@company = Company.find(params[:id])
if request.xhr?
# add the given tag to the company
@company.tags << params[:company][:taglist]
@company.save
render :partial => 'tags'
else
if @company.update_attributes(params[:company])
flash[:notice] = "Successfully updated company."
redirect_to @company
else
render :action => 'edit'
end
end
end
幫助...?
DELETE /companies/:company_id/contacts/:id(.:forma
{:controller=>"contacts", :action=>"destroy"}
companies GET /companies(.:format)
{:controller=>"companies", :action=>"index"}
POST /companies(.:format)
{:controller=>"companies", :action=>"create"}
new_company GET /companies/new(.:format)
{:controller=>"companies", :action=>"new"}
edit_company GET /companies/:id/edit(.:format)
{:controller=>"companies", :action=>"edit"}
company GET /companies/:id(.:format)
{:controller=>"companies", :action=>"show"}
PUT /companies/:id(.:format)
{:controller=>"companies", :action=>"update"}
DELETE /companies/:id(.:format)
{:controller=>"companies", :action=>"destroy"}
你有什麼在你的路由設置文件的公司?此外,你有公司控制器中的更新方法嗎?另外,我不知道它是否會受到傷害,但我不相信你在'form_remote_tag'方法中'公司'之前需要斜線。 – William 2010-10-26 00:25:14
我有一個更新方法....這裏是路線....(上面) – Angela 2010-10-26 01:07:04