开发者

What about this Ruby form does not work?

I can make a new , and that seems to work. But edit/update does not.

My controller :

def edit
  @admin_wysi = AdminWysi.find(params[:id])
end

def update
  @admin_wysi = AdminWysi.find(params[:id])

  if @admin_wysi.update_attributes(params[:admin_wysis])
    redirect_to admin_admin_wysis_path
  end
end

And my HAML..

- form_for @admin_wysi, :url => admin_admin_wysis_path do |f|
  = f.cktext_area :post_published, :cols => '70', :rows => '30', :width => '555px', :height => '240px', :toolbar => 'HQ'
  = f.submit 'Updat开发者_StackOverflow社区e', {:class => 'button'}

This is literally copy and pasted practically from my "new", so I'm guessing the problem HAS to be from my controller. Also there are no errors, and the SQL is identical in its injections as it was with the 'new'.

Thanks a bazillion everyone.


you need to have an edit form that is slightly different

- form_for @admin_wysi, :url => admin_admin_wysis_path(@admin_wysi) do |f|

And that should be edit.html.haml

UPDATE: it appears you have already done this but you need the following line in your routes.rb in order for the named routes to work.

map.name_space :admin do |admin|
  admin.resources :admin_wysi
end

UPDATE: that should be

- form_for @admin_wysi, :url => admin_admin_wysi_path(@admin_wysi) do |f|

to trigger the update action.


Shouldn't it be

@admin_wysi.update_attributes(params[:admin_wysi]

instead of

@admin_wysi.update_attributes(params[:admin_wysis]

?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜