Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
2eeeb266
Commit
2eeeb266
authored
Mar 18, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse `for_commit?` on conditional validations
parent
a5bad465
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
app/models/todo.rb
app/models/todo.rb
+2
-2
No files found.
app/models/todo.rb
View file @
2eeeb266
...
@@ -29,8 +29,8 @@ class Todo < ActiveRecord::Base
...
@@ -29,8 +29,8 @@ class Todo < ActiveRecord::Base
delegate
:name
,
:email
,
to: :author
,
prefix:
true
,
allow_nil:
true
delegate
:name
,
:email
,
to: :author
,
prefix:
true
,
allow_nil:
true
validates
:action
,
:project
,
:target_type
,
:user
,
presence:
true
validates
:action
,
:project
,
:target_type
,
:user
,
presence:
true
validates
:target_id
,
presence:
true
,
if:
->
(
t
)
{
t
.
target_type
.
present?
&&
t
.
target_type
!=
'Commit'
}
validates
:target_id
,
presence:
true
,
unless: :for_commit?
validates
:commit_id
,
presence:
true
,
if:
->
(
t
)
{
t
.
target_type
.
present?
&&
t
.
target_type
==
'Commit'
}
validates
:commit_id
,
presence:
true
,
if:
:for_commit?
default_scope
{
reorder
(
id: :desc
)
}
default_scope
{
reorder
(
id: :desc
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment