Forum: Ruby on Rails saving ActiveRecord/Form data changes??

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.
D6b59073324903562ab6b0142195719c?d=identicon&s=25 Bill Butler (zambezi)
on 2009-01-27 22:46
Greetings everyone,

This post has been moved (on suggestion) from the Ruby forum.

I can't pass updated/changed values from the form elements to the
ActiveRecord.  However something is going through because the table's
update_when column is registering the date/time of the update, but
otherwise no data revisions to other columns transpire.  Have tried
using form_for helper as well, but the same results.

This is all new to me, so not sure what additional info will be
relevant.  But am using Ruby 1.8.6 with a local MYSQL 5.1 database thru
a Radrails IDE.  My apologies for whatever info I have ommitted.  Any
suggestions on where I have gone astray will be most appreciated.

Thanks, Bill


CONTROLLER:

class FileController < ApplicationController

def edit
    @file = File.find(params[:id])
end

def update
    @file = File.find(params[:id])
    if @file.update_attributes(params[:file])
        redirect_to :action => 'show', :id => @file
    else
        render :action => 'edit'
    end
end
end

VIEW:

<% form_tag (:action => 'update', :id => @file.id) do %>

<p><label for="file_description">Description</label><br>
<%= text_area 'file', 'description' </p>

<%= submit_tag 'Save changes' %>
<% end %>

<%= link_to 'Back', {:action => 'list'} %>
This topic is locked and can not be replied to.