Forum: Ruby on Rails Ignorant FileColumn question

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.
Andrew F. (Guest)
on 2005-12-13 00:19
(Received via mailing list)
I am trying to use file column to update a record that is already
created in the DB. Here is how things work. I allow the user to
create a new Entry dynamically. That entry can have an image
associated so i build a form that allows the user to upload an image.
The image upload is passed to a action that is supposed to update the
image column but nothing ever happens. I know this is an ignorant
question fairly new to rails and this is one of the last things I
need to add to my app that is base functionailty. From here it is all
some advanced work and cleanup.

My model has the following:

file_column :image

my controller has:

	def update_image
		@entry= Entry.find(params[:id])
		@entry.update_attributes(:image => params[:image],
		                            			:entry_label => "Nothing",
								:required => "0")
		@company = Company.find(:first,
     								:conditions => "id = '#{session[:current_company]}' and
user_id = '#{@user.id}'")
     		@entrys = Entry.find(:all,
   						      :conditions => ["companyy_id = ?", @company.id],
   						       :order => "q_order ASC")
		redirect_to :action => 'page2'
	end

my view looks like this (this view is a partial that is called from
the page2 view from the controller above)

<%= form_tag :action => 'update_image', :multipart => true %>

			Your Text:<br/>
			<%= file_column_field 'entry', 'image' %>
			<br/>
			<%= hidden_field_tag(:id, @entry.id) %>
			<%= submit_tag("Update") %>
<%= end_form_tag %>

Sorry for the dumb question I know that this is probably me just
staring at the code for to long and I am going to slap myself when i
get this working.

Andrew
Sebastian K. (Guest)
on 2005-12-13 01:02
(Received via mailing list)
Hi Andrew,

On 12/12/05, Andrew F. <removed_email_address@domain.invalid> wrote:
>                                                                 :required => "0")
You should say @entry.update_attributes(params[:entry]), here, I
believe. If you look at the code generated by your view, you'll see
that the image upload field is named "entry[image]" and another hidden
field "entry[image_temp]".

Hope this helps
Sebastian
Andrew F. (Guest)
on 2005-12-13 03:47
(Received via mailing list)
Ok one more dumb question and this one I feel real stupid about. I am
able to get the app to create the temp directory when I select an
image to upload however I get a

undefined method `original_filename' for
{"image_temp"=>""}:HashWithIndifferentAccess


I noticed in the doc that under the rails_file_column.rb file it says
require this file in your environment.rb file. I have tried every
combination I can think of and either I get a 500 server error or I
get the above error again. I made the change to the controller as
Sebastion mentioned and have only gotten this far. When I originally
installed file_column the directory in the vendor/plugin directory
was called trunk. I have left it that way as well as changed it to
read file_column and tried every other thing I know of. Is it this
require issue or is something else missing?

Andrew
Andrew F. (Guest)
on 2005-12-13 04:05
(Received via mailing list)
Ok one more dumb question and this one I feel real stupid about. I am
able to get the app to create the temp directory when I select an
image to upload however I get a

undefined method `original_filename' for
{"image_temp"=>""}:HashWithIndifferentAccess


I noticed in the doc that under the rails_file_column.rb file it says
require this file in your environment.rb file. I have tried every
combination I can think of and either I get a 500 server error or I
get the above error again. I made the change to the controller as
Sebastion mentioned and have only gotten this far. When I originally
installed file_column the directory in the vendor/plugin directory
was called trunk. I have left it that way as well as changed it to
read file_column and tried every other thing I know of. Is it this
require issue or is something else missing?

Andrew
This topic is locked and can not be replied to.