Hello.
I'll try to help.

In our Gemfile we have:
gem "rails", "3.0.3"
gem "hobo", :git => "http://github.com/tablatom/hobo.git";, :branch =>
"rails3"
gem "paperclip", "2.3.8"

In our vendor/plugins folder we have the paperclip_with_hobo plugin.

In our application.dryml file we include the plugin with this line:
<include src="paperclip" plugin="paperclip_with_hobo"/>

Done. (Don't forget to restart the server.)

Let's try to add an avatar to our users.
In our User model, we add the avatar field (actually there are more
fields associated with the avatar - in a moment we'll se that):
-
has_attached_file :avatar,
    :styles => { :normal => "48x48>", :small => "36x36>" },
    :default_style => :normal,
    :default_url => "/images/user-avatar-:style.png",
    :url => "/
system/:class/:attachment/:id/:basename-:style.:extension"
-

Let's migrate: rails g hobo:migration
Now we see the 4 fields that we need to add to our users table; let's
create the migration and migrate.

For the view layer:
In the auto-generated view for editing the user (for example) now we
see that ugly form with those 4 fields.
Replace the form field-list with something like this:
-
<field-list: fields="name, email_address, avatar" />
-

Since we will use an avatar for many models, we created a DRYML tag to
show the avatar in the application.dryml file:
-
<def tag="avatar" attrs="size">
  <% size ||= "normal" %>
  <div class="avatar">
    <img src="&this.avatar.url(size.to_sym)" />
  </div>
</def>
-

This tag receives a size attribute (one of the avatar's field options
in the User model: normal or small, in our case).

Now if we want to show the logo in the users show page we just add:
<logo />

Done... I think this covers a simple use of the paperclip gem/plugin
(forgive me if it contains any errors or problems).

Cheers.
Tim

-- 
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.

Reply via email to