views:

27

answers:

2

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 'Update', {: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.

+2  A: 

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.

Geoff Lanotte
Ah Yes, my routes.rb already looks like that. Interesting. I set up a regular scaffold and that didn't specify that kinda thing. Anyways, I tried it, and I got this , "ActionController::MethodNotAllowed (Only get and post requests are allowed.):"
Trip
Though when i make it plural as in admin_admin_wysis_path(@admin_wysis), it'll pull through with no errors, but still no updated attributes.
Trip
yes, minor adjsutment admin_admin_wysi_path instead of admin_admin_wysis_path.
Geoff Lanotte
+1  A: 

Shouldn't it be

@admin_wysi.update_attributes(params[:admin_wysi]

instead of

@admin_wysi.update_attributes(params[:admin_wysis]

?

j.
That's what I had originally, but wasn't getting any errors. I switched it back though.
Trip