Myth17
2012-Mar-05 13:23 UTC
NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
I am presented with this error in my code, the line number happens to be --> Filestore.create(:filename => uploaded_file.original_filename , :fileblob => uploaded_file.open, :bunch => @current_bunch ) The code directly uses gsub nowehere, what could be the possible issue? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/5WejgZVH9yMJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law
2012-Mar-05 13:43 UTC
Re: NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
On 5 March 2012 13:23, Myth17 <nitishupreti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am presented with this error in my code, the line number happens to be --> > > Filestore.create(:filename => uploaded_file.original_filename , :fileblob => > uploaded_file.open, :bunch => @current_bunch )It probably means you are passing a parameter of the wrong type, so the underlying code is calling gsub, expecting it to be a string I imagine, but it is actually a File. What is a Filestore? You should use the techniques described in the Rails Guide on Debugging to break in and inspect the data to check that it is what you expect. Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Myth17
2012-Mar-05 15:05 UTC
Re: NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
FileStore is my model name and I have a table too. On Monday, March 5, 2012 7:13:38 PM UTC+5:30, Colin Law wrote:> > On 5 March 2012 13:23, Myth17 <nitishupreti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am presented with this error in my code, the line number happens to be > --> > > > > Filestore.create(:filename => uploaded_file.original_filename , > :fileblob => > > uploaded_file.open, :bunch => @current_bunch ) > > It probably means you are passing a parameter of the wrong type, so > the underlying code is calling gsub, expecting it to be a string I > imagine, but it is actually a File. > > What is a Filestore? You should use the techniques described in the > Rails Guide on Debugging to break in and inspect the data to check > that it is what you expect. > > Colin > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/D1Hc2owEpPQJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Myth17
2012-Mar-05 18:44 UTC
Re: NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
I used the puts with ''instance''.class to check the types and they match as well. On Monday, March 5, 2012 7:13:38 PM UTC+5:30, Colin Law wrote:> > On 5 March 2012 13:23, Myth17 <nitishupreti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am presented with this error in my code, the line number happens to be > --> > > > > Filestore.create(:filename => uploaded_file.original_filename , > :fileblob => > > uploaded_file.open, :bunch => @current_bunch ) > > It probably means you are passing a parameter of the wrong type, so > the underlying code is calling gsub, expecting it to be a string I > imagine, but it is actually a File. > > What is a Filestore? You should use the techniques described in the > Rails Guide on Debugging to break in and inspect the data to check > that it is what you expect. > > Colin > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/QaFxsdSZJGUJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Myth17
2012-Mar-05 19:07 UTC
Re: NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
I was incorrectly using instance variables which I replaced with session variables. However the problem persists. On Monday, March 5, 2012 7:13:38 PM UTC+5:30, Colin Law wrote:> > On 5 March 2012 13:23, Myth17 <nitishupreti-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am presented with this error in my code, the line number happens to be > --> > > > > Filestore.create(:filename => uploaded_file.original_filename , > :fileblob => > > uploaded_file.open, :bunch => @current_bunch ) > > It probably means you are passing a parameter of the wrong type, so > the underlying code is calling gsub, expecting it to be a string I > imagine, but it is actually a File. > > What is a Filestore? You should use the techniques described in the > Rails Guide on Debugging to break in and inspect the data to check > that it is what you expect. > > Colin > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/m5O6KA2mlCIJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Myth17
2012-Mar-05 19:16 UTC
Re: NoMethodError (undefined method `gsub'' for #<File:0x007faa7258fd80>) when gsub was never used!
Replacing open with read solved this issue. Thanks everyone! On Monday, March 5, 2012 6:53:34 PM UTC+5:30, Myth17 wrote:> > I am presented with this error in my code, the line number happens to be > --> > > Filestore.create(:filename => uploaded_file.original_filename , :fileblob > => uploaded_file.open, :bunch => @current_bunch ) > > The code directly uses gsub nowehere, what could be the possible issue? >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/v7Bt6fzwlmAJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.