oliver barnes
2005-Aug-17 19:11 UTC
(newbie) #{method}_relative_path empty (file upload 0.1.2)
first off, thanks (a lot!) sebastian for creating this module... I''ve been spending a lot of time in getting file uploads to work. inside a project I''m working on, I''ve got two different models using it... with one of them it''s working just fine. with another, everything works, with the exception of the url_for_file_column helper, which shows /entry/file_column/ but not the relative path (/ entry_id/file_name), so it writes this: /photo/file// looks like file_relative_path isn''t returning the path, though there''s a file name written to a ''file'' column in the database table. I examined the source for the module, but couldn''t find where it breaks, if anything I''m doing is conflicting with the module for instance. here''s the model require_dependency ''rails_file_column'' class Photo < ActiveRecord::Base belongs_to :user file_column :file def set_to_last_position position = user.photos.size + 1 end def before_create set_to_last_position end end any ideas why FileColumn wouldn''t find the file''s relative path? thanks oliver
Sebastian Kanthak
2005-Aug-18 13:25 UTC
Re: (newbie) #{method}_relative_path empty (file upload 0.1.2)
On 8/17/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> inside a project I''m working on, I''ve got two different models using > it... with one of them it''s working just fine. with another, > everything works, with the exception of the url_for_file_column > helper, which shows /entry/file_column/ but not the relative path (/ > entry_id/file_name), so it writes this: > > /photo/file//hmm, I don''t know exactly what is causing this, but considering the (im-)maturity of file_column it''s most probably a bug in my code :) Could you help me debuging this by providing me with the following information? * Start up the console (e.g. "./script/console") * Load the photo object you are refering to (e.g type "p = Photo.load(42)") * Look at the attributes (e.g. type "p.attributes") * and the file_relative_path (type "p.file_relative_path") If you send me the output of the above session I can hopefully find the bug. BTW, you should remove the "require_dependcy ''rails_file_column''" from your model and put "require ''rails_file_column''" at the bottom of your "config/environment.rb" instead. Thanks Sebastian
oliver barnes
2005-Aug-18 18:53 UTC
Re: (newbie) #{method}_relative_path empty (file upload 0.1.2)
hi sebastian, I got it working afterwards, after changing naming around... I tried to avoid using ''file'' as the column for file_column. not positive whether this was the issue though, i did a lot of tinkering around late at night... . it might just have been a newbie oversight somewhere :P I am going to begin using the console after your tip though, hadn''t looked into this tool yet. and any further feedback I have I''ll send you with this session. I put require_dependency ''rails_file_column'' inside environment... I had before, but it didn''t work at first for some reason. working smoothly now. thanks again for creating this! i''m going to use it a lot, and hope to send better feedback in the future ;) - Oliver On Aug 18, 2005, at 10:25 AM, Sebastian Kanthak wrote:> On 8/17/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> inside a project I''m working on, I''ve got two different models using >> it... with one of them it''s working just fine. with another, >> everything works, with the exception of the url_for_file_column >> helper, which shows /entry/file_column/ but not the relative path (/ >> entry_id/file_name), so it writes this: >> >> /photo/file// >> > > hmm, I don''t know exactly what is causing this, but considering the > (im-)maturity of file_column it''s most probably a bug in my code :) > > Could you help me debuging this by providing me with the following > information? > > * Start up the console (e.g. "./script/console") > * Load the photo object you are refering to (e.g type "p = > Photo.load(42)") > * Look at the attributes (e.g. type "p.attributes") > * and the file_relative_path (type "p.file_relative_path") > > If you send me the output of the above session I can hopefully find > the bug. BTW, you should remove the "require_dependcy > ''rails_file_column''" from your model and put "require > ''rails_file_column''" at the bottom of your "config/environment.rb" > instead. > > Thanks > Sebastian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
oliver barnes
2005-Aug-26 19:15 UTC
newbie question - url_for_file_column not working (file upload 0.1.2) (was: #{method}_relative_path empty)
hi sebastian, I''ve encountered this same issue again, and I''m sending the debug info you asked for a while back: ## ''load'' didn''t work, so I tried ''find'' >> p = Photo.load(37) TypeError: cannot convert Fixnum into String from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1/ lib/active_support/dependencies.rb:193:in `load'' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.1.1/ lib/active_support/dependencies.rb:193:in `load'' from (irb):12 >> p = Photo.find(37) => #<Photo:0x22f4650 @attributes={"approved_on"=>nil, "blocked_on"=>nil, "arquivo"=>"30209_square.jpg", "updated_on"=>"2005-08-26 15:36:02", "id"=>"37", "talent_id"=>"366", "position"=>"3", "created_at"=>"2005-08-26 15:36:02"}> >> p.attributes => {"blocked_on"=>nil, "approved_on"=>nil, "arquivo"=>"30209_square.jpg", "updated_on"=>Fri Aug 26 15:36:02 BRT 2005, "id"=>37, "talent_id"=>366, "position"=>3, "created_at"=>Fri Aug 26 15:36:02 BRT 2005} >> p.arquivo_relative_path => "37/30209_square.jpg" >> arquivo_relative_path returns the right path, and I''m using it directly for now, but url_for_file_column("photo", "arquivo") is just giving me "/photo/arquivo//.png" thanks Oliver On Aug 18, 2005, at 10:25 AM, Sebastian Kanthak wrote:> On 8/17/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> inside a project I''m working on, I''ve got two different models using >> it... with one of them it''s working just fine. with another, >> everything works, with the exception of the url_for_file_column >> helper, which shows /entry/file_column/ but not the relative path (/ >> entry_id/file_name), so it writes this: >> >> /photo/file// >> > > hmm, I don''t know exactly what is causing this, but considering the > (im-)maturity of file_column it''s most probably a bug in my code :) > > Could you help me debuging this by providing me with the following > information? > > * Start up the console (e.g. "./script/console") > * Load the photo object you are refering to (e.g type "p = > Photo.load(42)") > * Look at the attributes (e.g. type "p.attributes") > * and the file_relative_path (type "p.file_relative_path") > > If you send me the output of the above session I can hopefully find > the bug. BTW, you should remove the "require_dependcy > ''rails_file_column''" from your model and put "require > ''rails_file_column''" at the bottom of your "config/environment.rb" > instead. > > Thanks > Sebastian > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Sebastian Kanthak
2005-Aug-28 16:47 UTC
Re: newbie question - url_for_file_column not working (file upload 0.1.2) (was: #{method}_relative_path empty)
Hi Oliver, On 8/26/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ve encountered this same issue again, and I''m sending the debug > info you asked for a while back:[snip]> >> p.arquivo_relative_path > => "37/30209_square.jpg" > >> > > arquivo_relative_path returns the right path, and I''m using it > directly for now, but url_for_file_column("photo", "arquivo") is > just giving me "/photo/arquivo//.png"hmm, this is very strange, because url_for_file_column is just calling the "arquivo_relative_path" method. Could you add some debug code to your view? <%= debug @photo %> <%= @photo.arquivo_relative_path %> <%= url_for_file_column "photo", "arquivo" %> Hopefully I can figure out what''s going on here, soon. Sebastian PS: Are you using version 0.1.3?
oliver barnes
2005-Aug-30 00:47 UTC
Re: newbie question - url_for_file_column not working (file upload 0.1.2) (was: #{method}_relative_path empty)
hey sebastian, here''s the output for the debug code: --- !ruby/object:Photo attributes: arquivo: 30209_square.jpg id: "37" created_at: 2005-08-26 15:36:02 37/30209_square.jpg /photo/arquivo/ and I forgot to mention, this is inside a partial (_photo.rhtml, with locals named after this). could this be the problem? i''m using 0.1.3. with another object using file_column, it works fine: --- &id001 !ruby/object:User attributes: name: '''' photo: 000037_1.jpg 366/000037_1.jpg /user/photo/366/000037_1.jpg thanks Oliver On Aug 28, 2005, at 1:47 PM, Sebastian Kanthak wrote:> hmm, this is very strange, because url_for_file_column is just calling > the "arquivo_relative_path" method. Could you add some debug code to > your view? > > <%= debug @photo %> > <%= @photo.arquivo_relative_path %> > <%= url_for_file_column "photo", "arquivo" %> > > Hopefully I can figure out what''s going on here, soon. > > Sebastian > > PS: Are you using version 0.1.3?
Sebastian Kanthak
2005-Aug-30 03:55 UTC
Re: newbie question - url_for_file_column not working (file upload 0.1.2) (was: #{method}_relative_path empty)
On 8/30/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> and I forgot to mention, this is inside a partial (_photo.rhtml, with > locals named after this). could this be the problem?is the photo object inside a local variable or an instance variable (e.g. photo or @photo)? url_for_file_column only works with instance variables, like all other active record form helpers. Could this be the problem? Sebastian
oliver barnes
2005-Aug-31 00:04 UTC
Re: newbie question - url_for_file_column not working (file upload 0.1.2) (was: #{method}_relative_path empty)
it''s inside a local variable, that must be it. didn''t know there was this distinction, thanks once again sebastian. On Aug 30, 2005, at 12:55 AM, Sebastian Kanthak wrote:> On 8/30/05, oliver barnes <ol1barn3s-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> and I forgot to mention, this is inside a partial (_photo.rhtml, with >> locals named after this). could this be the problem? >> > > is the photo object inside a local variable or an instance variable > (e.g. photo or @photo)? url_for_file_column only works with instance > variables, like all other active record form helpers. Could this be > the problem? > > Sebastian >