1) installation is not as smooth as some other plug-ins. If you follow the instructions on http://www.kanthak.net/opensource/file_column/ it makes a directory called trunk instead of file_column. You have to manually rename it to file_column. I guess this is a minor annoyance but it gives me the feeling that things aren''t quite like other plugins. 2) I get this error: undefined method `file_column'' for Mymodel:Class after following the directions to to that on the same page. I thought it was maybe because I had to add require ''rails_file_column'' to environment.rb but I still get the same error Does anyone have an example of a getting this plugin working? A complete example would be great (model, list and form views, and controller, and schema) http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn only has model and view code thanks! -- Posted via http://www.ruby-forum.com/.
in the db you need a text type column for the path that is stored in the
coresponding model; so the whole story would go like this:
Db:
(1)
some_table
id int ..
foo (file_column_field--you can call this whatever you want--)
varchar(255) not null..
..
primary key (id) ..
(2)you must download the file_column instructions from sabastian''s page
(it''s actually quite simple; just copy the ruby script/plugin install
http:// ... into the directory of your application (it is done for every
application, not entirely for rails, as far as i know)
(3)in the model of SomeTable, put:
Class SomeTable
file_column :foo
end
(4) to put it in a form do:
start_form_tag ({:action => ... }, :mulitpart => true ) # so that it can
recieve
files, encoding issues..
..
..
..
file_column_field ''some_table'', ''foo''
end_form_tag
and then, to get the relative path to the file that was downloaded do:
@var = SomeTable.find(theoneyouwant)
url_for_file_column("var", "foo")
to get what you want.
[[[
can be image_tag(url_for_file_column("var", "foo")) or
link_to(url_for_file_column("var", "foo")) etc.
]]]
hope it helps.
harp
--
Posted via http://www.ruby-forum.com/.
Thanks, Harp! It works, mostly. It works great in my new, edit, and show methods, but not in the list method. The error I get is: Showing app/views/cabmembers/list.rhtml where line #6 raised: You have a nil object when you didn''t expect it! The error occured while evaluating nil.logo_relative_path Extracted source (around line #6): 3: <% for cabmember in @cabmembers %> 4: <div class="cabmember"> 5: <div class="cabmemberlogo"> 6: <%= image_tag url_for_file_column( ''cabmember'', ''logo'' ) %> 7: </div> I think the nil object has something to do with me not knowing how to pass url_for_file_column the right info?? Any ideas? -- Posted via http://www.ruby-forum.com/.
I believe url_for_file_column requires an instance variable (i.e. one with an @ before it). So you could try this: <% for @cabmember in @cabmembers %> <div class="cabmember"> <div class="cabmemberlogo"> <%= image_tag url_for_file_column( ''cabmember'', ''logo'' ) %> </div> -Greg On 8/18/06, Ivan Storck <ivan@fiya.com> wrote:> Thanks, Harp! It works, mostly. It works great in my new, edit, and show > methods, but not in the list method. The error I get is: > > Showing app/views/cabmembers/list.rhtml where line #6 raised: > > You have a nil object when you didn''t expect it! > The error occured while evaluating nil.logo_relative_path > > Extracted source (around line #6): > > 3: <% for cabmember in @cabmembers %> > 4: <div class="cabmember"> > 5: <div class="cabmemberlogo"> > 6: <%= image_tag url_for_file_column( ''cabmember'', ''logo'' ) %> > 7: </div> > > > I think the nil object has something to do with me not knowing how to > pass url_for_file_column the right info?? Any ideas? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
This is a late reply, but I''m also having problems with file_column The svn install didn''t work so I copied the files manually into vendor/plugins and renamed the dir file_column I think my problem is in the require statements in environment.rb At the moment I have require ''file_column'' require ''file_column_helper'' require ''rails_file_column'' at the bottom of the environment.rb file. Im not sure about the syntax here, in particular whether I need to specify the filepath, or move these from the vendor folder to a higher lib. Im also not sure if they are in the correct place in the environment.rb file. The error I am getting is when trying to save the file; Do not know how to handle a string with value ''060910 rebecca cannon radio.jpg'' that was passed to a file_column. Check if the form''s encoding has been set to ''multipart/form-data''. (Even tho my form specifies multipart: <%= start_form_tag :action => ''create'', :multipart => true %> Any suggestions appreciated. -- 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 -~----------~----~----~----~------~----~------~--~---
user error syntax problem as usual
<%= start_form_tag :action => ''create'', :multipart =>
true %>
should have been
<%= start_form_tag({:action => ''create''}, {:multipart
=> true}) %>
--
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
-~----------~----~----~----~------~----~------~--~---