-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c189cd8
commit 4cffc27
Showing
5 changed files
with
10 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ def index | |
end | ||
|
||
def rnd | ||
@excuse = Excuse.find_rnd | ||
@msg = Excuse.find_rnd.msg['es'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
class Excuse | ||
include Mongoid::Document | ||
field :lang, type: Symbol, default: :es | ||
field :description, type: String | ||
|
||
# Hash like { lang => msg } | ||
field :msg, type: Hash | ||
|
||
def self.find_rnd | ||
where(lang: :es).sample | ||
all.sample | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
- @excuses.each do |excuse| | ||
p = excuse.description | ||
p = excuse.msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
#main-excuse | ||
- if @excuse | ||
= @excuse.description | ||
- else | ||
No excuses available | ||
= @msg || 'No excuses available' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Excuse.all.each do |e| | ||
e.remove | ||
end | ||
Excuse.create(description: 'Hoy hace mucha humedad') | ||
Excuse.create(description: 'Esta roca se desace mucho') | ||
Excuse.create(description: 'Si fuera un poco mas alto...') | ||
Excuse.create(msg: { es: 'Hoy hace mucha humedad' } ) | ||
Excuse.create(msg: { es: 'Esta roca se desace mucho' } ) | ||
Excuse.create(msg: { es: 'Si fuera un poco mas alto...' } ) |