Hi Matt,
Thanks! Got it working. For anyone else who wants to do this, this is what I
did:
class Gmeeting < ActiveRecord::Base
hobo_model # Don't put anything above this
fields do
title :string, :required
speaker :string, :required
talkdate :date, :required
abstract :text
timestamps
end
has_attached_file :presentation, :path =>
":rails_root/public/group-meetings/:speaker/:talkdate/:basename.:extension"
# interpolate in paperclip
private
Paperclip.interpolates :speaker do |attachment, style|
attachment.instance.speaker
end
private
Paperclip.interpolates :talkdate do |attachment, style|
attachment.instance.talkdate
end
end
I also found this page to be very helpful:
http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip
Cheers,
Ben
On 17 August 2011 23:24, Matt Jones <[email protected]> wrote:
>
> On Aug 17, 2011, at 2:51 AM, Ben SV wrote:
>
> > Hi,
> >
> > Firstly I'm new to Ruby, Rails & Hobo so please forgive me if this is
> > a trivial question.
> >
> > I'm using paperclip to attach files and I would like to set the upload
> > URL to reflect variables within the model, shown below:
> >
> > class Gmeeting < ActiveRecord::Base
> >
> > hobo_model # Don't put anything above this
> >
> > fields do
> > title :string, :required
> > speaker :string, :required
> > talkdate :date, :required
> > abstract :text
> > timestamps
> > end
> >
> > has_attached_file :presentation, :path => ":rails_root/public/group-
> > meetings/SPEAKER/DATE/:basename.:extension"
> > end
> >
> > In the path variable can I make SPEAKER equal the speaker field and
> > DATE equal the talkdate field?
>
> You should be able to set up interpolations to do this:
>
> https://github.com/thoughtbot/paperclip/wiki/Interpolations
>
> --Matt Jones
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.