active scaffold upload branch

13 views
Skip to first unread message

timcharper

unread,
May 4, 2007, 11:41:19 AM5/4/07
to ActiveScaffold : Ruby on Rails plugin
I have been working on an active scaffold branch for some time that
supports file uploads via posting through an I-frame (Ajax style file
uploads). It is working very well for me, and I am using it in many
projects. I will maintain this branch and keep it up-to-date every
time active scaffold has a release. the current branch is merged
against active scaffold rc2.

You can check it out at the following URL:
http://activescaffold.googlecode.com/svn/branches/upload

it includes a copy of Sean Treadway's response_to_parent.

at the time being, here is the way to enable file uploads, for both
create and also update. for this example, you will need the
file_column plug-in to facilitate your uploads.


::app/controllers/entries_controller.rb::
class EntriesController < ApplicationController
active_scaffold :entry do |config|
config.create.multipart = true
config.update.multipart = true
end
end

::app/views/entries/_form.rhtml::
<% fields_for :record do |f| %>
<%= f.text_field :name %>
<%= f.text_field :age %>
<%= file_column_field 'record', :file %>
<% end %>

::app/views/entries/_show.rhtml::
<ul>
<li><%= @record.name %></li>
<li><%= @record.age %></li>
<li><%= link_to 'url', url_for_file_column(@record, 'file') %></li>
</ul>


please post your issues to this list and not to the Google issue
tracker for the time being. We are planning to merge this into core
for 1.1.

Thanks, and enjoy!

Tim

jb

unread,
May 4, 2007, 2:58:41 PM5/4/07
to ActiveScaffold : Ruby on Rails plugin
Nice !

Sai Emrys

unread,
May 4, 2007, 5:11:50 PM5/4/07
to ActiveScaffold : Ruby on Rails plugin
How is this synchronized with trunk? Should I switch my version over,
or merge it somehow, or what?

- Sai

On May 4, 11:58 am, jb <jbden...@gmail.com> wrote:
> Nice !
>
> On May 4, 5:41 pm, timcharper <timchar...@gmail.com> wrote:
>
> > I have been working on an active scaffold branch for some time that

> > supportsfileuploads via posting through an I-frame (Ajax stylefile


> > uploads). It is working very well for me, and I am using it in many
> > projects. I will maintain this branch and keep it up-to-date every
> > time active scaffold has a release. the current branch is merged
> > against active scaffold rc2.
>
> > You can check it out at the following URL:http://activescaffold.googlecode.com/svn/branches/upload
>
> > it includes a copy of Sean Treadway's response_to_parent.
>

> > at the time being, here is the way to enablefileuploads, for both

Sai Emrys

unread,
May 4, 2007, 5:27:36 PM5/4/07
to ActiveScaffold : Ruby on Rails plugin
How is this synchronized with trunk? Should I switch my version over,
or merge it somehow, or what?

- Sai

On May 4, 11:58 am, jb <jbden...@gmail.com> wrote:

> Nice !
>
> On May 4, 5:41 pm, timcharper <timchar...@gmail.com> wrote:
>
> > I have been working on an active scaffold branch for some time that

> > supportsfileuploads via posting through an I-frame (Ajax stylefile


> > uploads). It is working very well for me, and I am using it in many
> > projects. I will maintain this branch and keep it up-to-date every
> > time active scaffold has a release. the current branch is merged
> > against active scaffold rc2.
>
> > You can check it out at the following URL:http://activescaffold.googlecode.com/svn/branches/upload
>
> > it includes a copy of Sean Treadway's response_to_parent.
>

> > at the time being, here is the way to enablefileuploads, for both

Tim Harper

unread,
May 4, 2007, 5:39:48 PM5/4/07
to actives...@googlegroups.com
You can just uninstall your version of active scaffold, then install active
scaffold upload like this:

Script/plugin install
http://activescaffold.googlecode.com/svn/branches/upload

(you'll probably want to rename the folder vendor/plugins/upload to
vendor/plugins/active_scaffold_upload or something)

Tim

Sai Emrys

unread,
May 4, 2007, 5:50:03 PM5/4/07
to ActiveScaffold : Ruby on Rails plugin
I've turned this patch into a pastie, so it'll be easier to see your
code & it can be added ad hoc as overrides:

http://pastie.caboo.se/private/fo6qug8lsjaqlpufur

Haven't tried it yet, will give you feedback when I do.

- Sai

Philipp

unread,
May 7, 2007, 12:31:23 PM5/7/07
to ActiveScaffold : Ruby on Rails plugin
Hi altogether,

if someone try the example from the top ..

dont forget to set the file column, otherwise it was not working for
me .. (server error 500)

e.g
class Article < ActiveRecord::Base
file_column :file <<<<<<<<<<<<<<<<<<<<<<
has_and_belongs_to_many :user
has_and_belongs_to_many :usergroup
has_one :frame
has_and_belongs_to_many :articlegroup

end


regards
Philipp

Sai Emrys

unread,
May 7, 2007, 8:07:52 PM5/7/07
to ActiveScaffold : Ruby on Rails plugin
Next question: how to add this as a has_many?

E.g. project has_many documents
document has a file_column :file plus other metadata (eg summary)...

Requires a subform override.

- Sai

steegi

unread,
Jun 12, 2007, 1:41:28 AM6/12/07
to ActiveScaffold : Ruby on Rails plugin
Hi Tim,

Thanks for the upload branch, nice job.

I wanted to take it for a spin but noticed it hasn't been merged with
trunk for a while, creating some incompatibilities with my current
project.

You mentioned the plan was/is to merge it into 1.1 of AS.
Do you perhaps have any updates? I.e. time frame for merge with trunk
either in the direction of the branch or in the direction of the
trunk.

Thanks, Frank.

Differenthink

unread,
Jun 12, 2007, 3:12:54 AM6/12/07
to ActiveScaffold : Ruby on Rails plugin
Is'n it possible to use it without file column ?
for example to store the file in a directory and not in DB...

Guillaume.

Matt

unread,
Jun 12, 2007, 11:43:39 AM6/12/07
to ActiveScaffold : Ruby on Rails plugin
This also works with attachment_fu pretty nicely.

One problem I have is using a HABTM relationship with the "attactment"

It keeps trying to force an id of 1 in the join table. So the first
create will work, but it'll never get beyond that.

Differenthink

unread,
Jun 12, 2007, 3:37:21 PM6/12/07
to ActiveScaffold : Ruby on Rails plugin
hum, maybe i should consider using attachment_fu and not do that by my
self...

so you re saying attachment_fu is compatible with tje upload branch of
AS ?

I ve seen some explaination of attachment_fu, and they all talking
about image etc..; do you know if i can use it to store things like
video (i only want to store them where i want in the public folder, i
have no need of resizing etc.. ) ?

thanks in advance,

Guillaume.

Matt

unread,
Jun 12, 2007, 4:34:00 PM6/12/07
to ActiveScaffold : Ruby on Rails plugin
Yah for me it works just fine. You just need to create a field called
"uploaded_data"

In your controller:

active_scaffold :picture do |config|


config.create.multipart = true
config.update.multipart = true

config.create.columns = [:uploaded_data]
end

Model:

class Picture < ActiveRecord::Base

has_and_belongs_to_many :products

has_attachment :content_type => :image,
:storage => :file_system,
:max_size => 3.megabytes,
:resize_to => '400x400>',
:thumbnails => {:medium => '200x200>', :small =>
'100x100>'},
:path_prefix => 'public/images/products'
validates_as_attachment

end

Helper:

def uploaded_data_form_column(record, input_name)
file_field_tag input_name
end


That should do it.

Differenthink

unread,
Jun 12, 2007, 4:58:42 PM6/12/07
to ActiveScaffold : Ruby on Rails plugin
Ok i ll try it.... but without the all picture stuff... i only need to
upload a "document" and a "video"...
By the way, is it possible to have multiple upload field in the same
model via fu_attachment ?
Reply all
Reply to author
Forward
0 new messages