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
Hi Andrew, On 12/12/05, Andrew Filipowski <a.filipowski-ee4meeAH724@public.gmane.org> wrote:> 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")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
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
On Dec 12, 2005, at 5:59 PM, Sebastian Kanthak wrote:
> Hi Andrew,
>
> On 12/12/05, Andrew Filipowski
<a.filipowski-ee4meeAH724@public.gmane.org> wrote:
>> 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],
>> :entr
>> y_label => "Nothing",
>> :requ
>> ired => "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
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
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
On Dec 12, 2005, at 5:59 PM, Sebastian Kanthak wrote:
> Hi Andrew,
>
> On 12/12/05, Andrew Filipowski
<a.filipowski-ee4meeAH724@public.gmane.org> wrote:
>> 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],
>> :entr
>> y_label => "Nothing",
>> :requ
>> ired => "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
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails