paperclip gem question.

15 views
Skip to first unread message

roelof

unread,
Oct 6, 2012, 11:40:16 AM10/6/12
to rubyonra...@googlegroups.com
Hello,

I decided that I use paperclip to handle my images.

I have this model for posts

class Micropost < ActiveRecord::Base
  attr_accessible :content, :user_id
    belongs_to :user
end

So according to the manual I have to do this :
has_attached_file :photo

But :photo is never used anywhere.

So do I have to change something or did I misunderstand the manual.

Roelof

BalaRaju Vankala

unread,
Oct 7, 2012, 6:35:32 AM10/7/12
to rubyonra...@googlegroups.com
Hi...
1.  in Gemfile add  this gem

gem "paperclip", "3.1.4"

2. bundle install
3.after creating model add below code in migration file(db->migrate->photo model migration file )

t.attachment:photo

4. rake db:migrate

5. in your model Add this code
attr_accessible: photo

has_attached_file :photo
   :path=>"rails_root/public/system/:attachment/:id/:style/:filename",
   :url=> "system/:attachment/:id/:style/:filename"


 



Roelof

--
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 rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/is2_0907w1QJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
నేను
కొంచం తపన,
 కాస్త ఆసక్తి,
కొన్ని కలలు,
 కాసిన్ని ఊహలు కలిపేస్తే
 నేను


Reply all
Reply to author
Forward
0 new messages