Do you upload files? Do you use active scaffold? If you answered yes to both of these questions, this solution is for you!
This small, easy plugin automatically gets you on the track to uploading files in Active Scaffold by tightly integrating in the file_column
To use, you’ll need the latest trunk version of Active Scaffold.
svn export http://activescaffold.googlecode.com/svn/trunk/ vendor/plugins/active_scaffold
Then, you’ll need file_column
script/plugin install http://filecolumn.googlecode.com/svn/tags/file_column
File Column Bridge is now in active scaffold core. Active Scaffold will automatically detect that File Column is installed, and will make use it.
Create a model with a file column:
# app/models/entry.rb # id integer # title string(255) # filename string(255) class Entry < ActiveRecord::Base file_column :filename end
Create your scaffold controller
# app/controllers/entries_controller.rb class EntryController < ApplicationController active_scaffold :entries end
and layout
# app/views/layouts/application.rhtml <html> <head> <title>active scaffold demo application</title> <%= javascript_include_tag :defaults %> <%= active_scaffold_includes %> </head> <body> <%= yield %> </body> </html>
That’s it! Your form input will be automatically set to a file upload box, and in the list view (and show view) the “filename” will link to the uploaded file. Righteous! Also, File Column Bridge fixes the issue so if you edit a record, and don’t
upload a file, the previous file is kept. Gnarly!
(NOTE: file column usage instructions included in the README file in the plugin’s directory)
If you have issues installing the plugin, post to the Active Scaffold Forums .
If you are having troubles with file_column itself, go to the file_column website.
Contact me:
Tim C. Harper - irb(main):001:0> ( 'tim_see_harperATgmail._see_om'.gsub('_see_', 'c').gsub('AT', '@') )
It is work for me only if I install Active Scaffold from http://activescaffold.googlecode.com/svn/trunk/
May be it’s help you too!
And thx a lot Tim for this wonderful plugin!
It doesn’t work for me if I have a configuration like that on my controller:
active_scaffold do |config|
config.actions = [:create,:list, :show, :update, :delete, :search, :nested]
config.list.columns = [:name,:link, :logo]
config.update.columns = [:name,:link, :logo]
#config.update.multipart = true
#config.create.multipart = true
config.create.columns = [:name,:link, :logo]
end
The error that pops up is this:
Update is not enabled. Please enable it or remove any references in your configuration (e.g. config.update.columns = [...]).
#{RAILS_ROOT}/vendor/plugins/active_scaffold/lib/config/core.rb:134:in `method_missing'
#{RAILS_ROOT}/vendor/plugins/active_scaffold_file_column_bridge/lib/active_scaffold_file_column_bridge.rb:19:in `initialize'
#{RAILS_ROOT}/vendor/plugins/active_scaffold/lib/active_scaffold.rb:47:in `new'
#{RAILS_ROOT}/vendor/plugins/active_scaffold/lib/active_scaffold.rb:47:in `active_scaffold'
#{RAILS_ROOT}/app/controllers/my_controller.rb:4
If I comment out the self.update.multipart call that provokes the error and activate it explicitly afterwards (see the two commented lines on my config above), it works like a charm.
ActionView::TemplateError (`@#<Requirement:0xb68a5b7c>' is not allowed as an instance variable name) on line #8 of vendor/plugins/active_scaffold/frontends/default/views/_show_columns.rhtml: 5: <dd><%= render :partial => 'show_columns' %></dd> 6: <% else -%> 7: <dt><%= column.label -%></dt> 8: <dd><%= get_column_value(@record, column) -%> </dd> 9: <% end -%> 10: <% end -%> 11: </dl>
Solution: Add the following two lines in controller
active_scaffold :entries do |conf| conf.create.link.page = true conf.update.link.page = true end
Parameters: {“commit”=>“Create”, “action”=>“create”, “controller”=>“entries”, “entry”=>{“filename_temp”=>””, “filename”=>“C:\\Documents and Settings\\ks37877\\Desktop\\d11e.jpg”}}
NoMethod Error (You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each):
/vendor/plugins/active_scaffold/lib/attribute_params.rb:32:in `update_record_from_params’
what am I missing that required to fix this issue when I upload any image file?
<dl> <dt>file</dt> <dd><%= file_column_field 'record', :filename %></dd> </dl>
It does works! thanks.
but in list the link is not activated? any help pls.