Initial commit
This commit is contained in:
0
app/models/.gitkeep
Normal file
0
app/models/.gitkeep
Normal file
10
app/models/ability.rb
Normal file
10
app/models/ability.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Ability
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize user
|
||||
user ||= User.new # guest access
|
||||
can :manage, Post, user_id: user.id
|
||||
can :read, Post
|
||||
end
|
||||
|
||||
end
|
||||
4
app/models/post.rb
Normal file
4
app/models/post.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Post < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
attr_accessible :body, :title, :user_id
|
||||
end
|
||||
11
app/models/user.rb
Normal file
11
app/models/user.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class User < ActiveRecord::Base
|
||||
# Include default devise modules. Others available are:
|
||||
# :token_authenticatable, :confirmable,
|
||||
# :lockable, :timeoutable and :omniauthable
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
# Setup accessible (or protected) attributes for your model
|
||||
attr_accessible :email, :password, :password_confirmation, :remember_me
|
||||
# attr_accessible :title, :body
|
||||
end
|
||||
Reference in New Issue
Block a user