Skip to content

Commit

Permalink
Merge pull request #32 from dannluciano/master
Browse files Browse the repository at this point in the history
Refactors in model User, and add the files for novice users
  • Loading branch information
Cairo Noleto committed Jun 14, 2011
2 parents 1fbfec8 + 1b84330 commit d0628bb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

* Faça um fork do projeto
* Faça as alterações com os respectivos testes (Este projeto utiliza o RSpec)
* Para fazer com seus testes executem automaticamente a cada alteração de arquivo, execute o guard na linha de comando
* Faça um pull request
* Código sem testes serão mais difíceis de ser aceitos ;)
10 changes: 7 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ class User < ActiveRecord::Base
has_many :roles
has_many :posts

attr_reader :role

def role_symbols
(roles || []).map { |r| r.title.to_sym }
end
Expand All @@ -21,7 +19,13 @@ def guest?
end

def role
@role = admin? ? "admin" : (member? ? "member" : "guest")
@role = if admin?
"admin"
elsif member?
"member"
else
"guest"
end
end

def change_role(value)
Expand Down
22 changes: 22 additions & 0 deletions config/database.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SQLite version 3.x
# gem install sqlite3
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000

0 comments on commit d0628bb

Please sign in to comment.