Hi guys Question about acts as attachment still getting the following error undefined method `content_type'' I have set everything up according to the following page however i am still have trouble http://weblog.techno-weenie.net/articles/acts_as_attachment One thing, I have wanted to add this to an existing model in my system. I have not used the... script/generate attachment_model dvd_cover to create my model it was already there. But i have added in all the lines that are needed. Any ideas about what i am doing wrong? Thanks for your time reading this -- 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 -~----------~----~----~----~------~----~------~--~---
On 11/19/06, Stewart <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi guys > > Question about acts as attachment still getting the following error > > undefined method `content_type'' > > I have set everything up according to the following page however i am > still have trouble > > http://weblog.techno-weenie.net/articles/acts_as_attachment > > > One thing, I have wanted to add this to an existing model in my system. > I have not used the... > > script/generate attachment_model dvd_cover > > to create my model it was already there. But i have added in all the > lines that are needed. Any ideas about what i am doing wrong? > > Thanks for your time reading thisCheck if your existing model has all the right attributes, such as the content_type column. -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
are you sure you installed from the correct source. i believe if your using edge, its a different version from stock. recheck the script/plugin install path. Stewart wrote:> Hi guys > > Question about acts as attachment still getting the following error > > undefined method `content_type'' > > I have set everything up according to the following page however i am > still have trouble > > http://weblog.techno-weenie.net/articles/acts_as_attachment > > > One thing, I have wanted to add this to an existing model in my system. > I have not used the... > > script/generate attachment_model dvd_cover > > to create my model it was already there. But i have added in all the > lines that are needed. Any ideas about what i am doing wrong? > > Thanks for your time reading this-- 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 -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:> On 11/19/06, Stewart <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> http://weblog.techno-weenie.net/articles/acts_as_attachment >> Thanks for your time reading this > Check if your existing model has all the right attributes, such as the > content_type column. > > > -- > Rick Olson > http://weblog.techno-weenie.net > http://mephistoblog.comthe model is correct. However because of the rest of my team i am unable to upgrade to 1.1.6. We are still on 1.1.2. -- 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 -~----------~----~----~----~------~----~------~--~---
Hey guys, I posted this a little while ago but I am still having trouble with it. I have install acts as attachment. I am using it with one of my existing models. Here is the model class Image < ActiveRecord::Base acts_as_attachment :storage => :file_system, :max_size => 300.kilobytes, :content_type => :image validates_as_attachment end I have set up the controller to do this... def upload_image @image = Image.new(params[:image]) if @image.save flash[:notice] = "Image uploaded" redirect_to :action => "image" else flash[:notice] = "Image upload error" redirect_to :action => "image" end end and this is my view %= start_form_tag :action => "upload_image", :multipart => true %> <p><label for="image_upload">Upload image form my computer...</lablel> <br> <%= file_field("image", "uploaded_data" ) %></p> <%= render :partial => "license" %> <%= submit_tag "Upload" %> I have got the following in my database create_table :images do |t| t.column :filename, :string t.column :size, :integer t.column :content_type, :string t.column :parent_id, :integer t.column :alt, :string t.column :resource_id, :int t.column :thumbnail, :string t.column :width, :integer t.column :height, :integer t.column :url, :string end Everytime i go to upload an image i get the following error undefined method `content_type'' for "image.jpg":String Any ideas would be great i am really stumped here -- 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 -~----------~----~----~----~------~----~------~--~---
On Nov 27, 2006, at 4:25 PM, Stewart wrote:> > %= start_form_tag :action => "upload_image", :multipart => true %>I just ran into this myself... try: start_form_tag( { :action => "upload_image" }, { :multipart => true } ) (i''m using the new 1.2 RC, so it was actually the following for me: <% form_tag( { :action => "upload_image" }, { :multipart => true } ) do %> ) -pete -- (peter.royal|osi)@pobox.com - http://fotap.org/~osi
> undefined method `content_type'' for "image.jpg":StringMake sure you have :multipart => true set correctly in the form tag. It''s trying to call params[:uploaded_data].content_type -- Rick Olson http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
peter royal wrote:> try: > > start_form_tag( { :action => "upload_image" }, { :multipart => true } ) > > (i''m using the new 1.2 RC, so it was actually the following for me: > > <% form_tag( { :action => "upload_image" }, { :multipart => true } ) > do %> > > ) > > -peteyea that was it thanks Peter and Rick!!!!!! -- 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 -~----------~----~----~----~------~----~------~--~---