i''ve changed store_dir to :store_dir => "public/uploads/users/pictures/" that works great for uploading, but url_for_file_column is still outputting: /user_picture/image/id/name.jpg how do i make url_for_file_column output the correct url? -- Posted via http://www.ruby-forum.com/.
I''m trying to upload an image that will be displayed alongside a user profile. I''ve been trying to use FileColumn but haven''t had any luck. I don''t receive any errors, I just don''t get the file on the server. Does anyone have any sample code they could share that demonstrates how I should use FileColumn? Thx Alex
Be certain your upload forms are multipart. Here is some working code.
in the model
----------
class InsuranceForm < ActiveRecord::Base
file_column :form_document
validates_presence_of :form_title
validates_presence_of :description
validates_presence_of :form_document
end
in the view
---------
<%= error_messages_for ''insurance_form'' %>
<%= start_form_tag({:action => ''create''}, :multipart
=> true) %>
<p><label for="insurance_form_form_title">Form
title</label><br/>
<%= text_field ''insurance_form'',
''form_title'' %></p>
<p><label
for="insurance_form_description">Description</label><br/>
<%= text_area ''insurance_form'',
''description'' %></p>
<p><label for="insurance_form_form_document">Form
document</label><br/>
<%= file_column_field ''insurance_form'',
''form_document'' %></p>
<%= end_form_tag %>
<%= link_to ''Back'', :action => ''list''
%>
in the controller
--------------
def new
@insurance_form = InsuranceForm.new
end
def create
@insurance_form = InsuranceForm.new(params[:insurance_form])
if @insurance_form.save
flash[:notice] = ''InsuranceForm was successfully
created.''
redirect_to :action => ''list''
else
render :action => ''new''
end
end
--
Posted via http://www.ruby-forum.com/.
Just wanted to say thanks for the info. Even though this was posted awhile ago, it helped me get my uploading to work!!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---