I have a quick question on a problem of mine.
I''ve done the ONLamp tutorial with scaffolding a recipe etc, and
honesly
I didn''t get really any wiser. So I decided to try it out on my own
without scaffolding.
However. Now I''m stuck with my edit-form. I need to update a row with
old text in the ''pres'' column in the table called
''presentations'' in my
database with a new text typed in with a form (in edit.rhtml).
My Edit method gets the ''pres'' from the
''presentations''table but it
doesn''t update the edited ''pres'' with the new text to
the database when
the submit button is clicked. I really can''t understand why not? What
is
wrong with my code?
---------------------
Model
---------------------
class Presentation < ActiveRecord::Base
belongs_to :user
end
---------------------
controller
---------------------
class PresentationController < ApplicationController
def info
@user_login = current_user.login
@user_presentation = current_user.presentation.pres
end
def edit
@presentation = current_user.presentation(params[:id])
end
def update
@presentation = current_user.presentation(params[:id])
if @presentation.update_attributes(params[:pres])
redirect_to :action => ''info''
else
render :action => ''edit''
end
end
end
---------------------
Edit view
---------------------
<% form_tag :action => ''update'', :id => @presentation
do %>
<p><label for="pres">Edit
Information</label><br/>
<%= text_area ''presentation'', ''pres''
%></p>
<p><%= submit_tag ''Update'' %></p>
<% end %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---