Forum: Ruby on Rails List and update values from text_field_tag fields

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jens Tinfors (Guest)
on 2006-03-09 00:50
(Received via mailing list)
Hi,

I populate a couple of text_field_tag's with data from an AciveRecord
object. Some fields are editable and at the end of the page there's a
submit button. I want the new values to be updated in the DB but by
default my original values are stored again.
How do i go about doing this?

thanks/jens

AIM: removed_email_address@domain.invalid
Skype: jtinfors
Norman T. (Guest)
on 2006-03-09 11:32
(Received via mailing list)
Am Mittwoch, den 08.03.2006, 23:47 +0100 schrieb Jens Tinfors:
> Hi,
>
> I populate a couple of text_field_tag's with data from an AciveRecord
> object. Some fields are editable and at the end of the page there's a
> submit button. I want the new values to be updated in the DB but by
> default my original values are stored again.
> How do i go about doing this?
>

Why don't you want your unchanged values stored again?

--
Norman T.

http://blog.inlet-media.de
Jens Tinfors (Guest)
on 2006-03-09 12:08
(Received via mailing list)
ohh, i dont mind the unchanged values stored again.
My problem (and its probably a very basic such) is how do i get the
newly
entered values from the text_field_tag's back into the db?

thanks/jens
Norman T. (Guest)
on 2006-03-09 13:06
(Received via mailing list)
Am Donnerstag, den 09.03.2006, 11:06 +0100 schrieb Jens Tinfors:
>         > I populate a couple of text_field_tag's with data from an
>         AciveRecord
>         > object. Some fields are editable and at the end of the page
>         there's a
>         > submit button. I want the new values to be updated in the DB
>         but by
>         > default my original values are stored again.
>         > How do i go about doing this?
>         >
>
>         Why don't you want your unchanged values stored again?

Ok, i see.

# code in your e.g. project controller

def update
  @project = Project.find(params[:project][:id])
  if @project.update_attributes(params[:project])
    flash[:notice] = 'Project updated'
    redirect_to :action => 'list'
  else
    render :action => new
  end
end

Perhaps you want to use the scaffold generator to generate some sample
code to see how everything works together.

Maybe you should follow a Rails tutorial like:

http://rails.homelinux.org/

--
Norman T.

http://blog.inlet-media.de
This topic is locked and can not be replied to.