Adding resources (imported from old toolshare)
This commit is contained in:
@@ -14,6 +14,7 @@ class Ability
|
||||
can [:update], Mac, :user_id => nil
|
||||
can [:create,:update], Mac, :user_id => user.id
|
||||
can :read, Payment, :user_id => user.id
|
||||
can :read, Resource
|
||||
can :read, UserCertification, :user_id => user.id
|
||||
can :read, User, :id => user.id #TODO: why can users update themselves? Maybe because Devise doesn't check users/edit?
|
||||
can :compose_email, User
|
||||
|
||||
12
app/models/resource.rb
Normal file
12
app/models/resource.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Resource < ActiveRecord::Base
|
||||
belongs_to :owner, :class_name => "ToolshareUser"
|
||||
belongs_to :category, :class_name => "ResourceCategory"
|
||||
has_attached_file :picture,
|
||||
:styles => { :medium => "300x300>",
|
||||
:thumb => "100x100>",
|
||||
:tiny => "50x50>"},
|
||||
:storage => :s3,
|
||||
:s3_credentials => Rails.root.join('config', 's3.yml'),
|
||||
:path => ":attachment/:id/:style.:extension",
|
||||
:bucket => 'Toolshare'
|
||||
end
|
||||
3
app/models/resource_category.rb
Normal file
3
app/models/resource_category.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class ResourceCategory < ActiveRecord::Base
|
||||
has_many :resources
|
||||
end
|
||||
4
app/models/toolshare_user.rb
Normal file
4
app/models/toolshare_user.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ToolshareUser < ActiveRecord::Base
|
||||
has_many :resources, :foreign_key => "owner_id"
|
||||
attr_accessible :name, :email
|
||||
end
|
||||
Reference in New Issue
Block a user