You don’t have to do anything unusual to handle a :file_column field in
the controller. If your varchar field is present in the database table
and the
:file_column fieldname
incantation is present in the model, you’re all set. And since it’s
working in the process_submit_story action (which is essentially what
the scaffold generates as a “create” action), you’ve got that set up
right.
I don’t know what you’re doing with that “stuff” method and :stuff
property in your process_admin_story action, though. You should model
this action on the “update” action generated by scaffolding, e.g.:
def process_admin_story
@story_entry= StoryEntry.find(params[:id])
if @story_entry.update_attributes(params[:story_entry])
flash[:notice] = ‘The story was successfully updated.’
redirect_to :action => ‘list’
else
render :action => ‘edit’
end
The key call is the update_attributes method, which… well… updates
whatever object attributes are present in the passed parameters, leaves
other attributes untouched, and then saves the changes.
Hope this helps.
Shark Fin S. wrote:
Hi Steve,
Form codes for new view:
<%= start_form_tag({:action => “process_submit_story”, :id =>
@story_entry.id}, :multipart => true) %>
<%= file_column_field “story_entry”, “image” %>
Form codes for edit view:
<%= start_form_tag({:action => “process_admin_story”, :id =>
@story_entry.id}, :multipart => true) %>
<%= file_column_field “story_entry”, “image” %>
In new controller, which works fine
@story_entry = StoryEntry.new params[:story_entry]
@story_entry.save
In admin controller, I don’t know how to do this
@story_entry.stuff = params[:story_entry][:stuff]
@story_entry.update
Sharkie