Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add save! to raise exception if things go wrong #19

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
732f9c6
Add save! to raise exception if things go wrong
Nov 20, 2014
2739020
revert whitespace change for easier merging
willbryant Jul 6, 2015
36c6653
merged rails/master
willbryant Jul 6, 2015
f17dd6b
Remove Gemfile.lock
Jul 5, 2016
209dfb3
Fix deprecation warnings
Jul 5, 2016
ccdfa22
Fix method signature for SimpleForm
Jul 5, 2016
a102adc
Fix attributes order in SimpleForm forms
Jul 5, 2016
939862e
Update README.md
Jul 5, 2016
faac7ec
Update License file
Jul 5, 2016
e4777dd
Update .gitignore
Jul 5, 2016
e893090
Fix deprecation warnings
Jul 5, 2016
1590bf4
Oopss.. typo
Jul 5, 2016
7a9dfb5
Remove empty lines
Jul 5, 2016
f39ef86
Setup tests with Appraisals
Jul 5, 2016
a7bb4c0
Fix warning
Jul 5, 2016
3238154
Add code coverage
Jul 5, 2016
72d9cb0
Update README.md
Jul 5, 2016
56542ca
Update README.md
Jul 5, 2016
2acfb03
Update README.md
Jul 5, 2016
30fe7b4
Fix tests with Rails 5 (part1)
Jul 5, 2016
6275c7b
Fix warning
Jul 5, 2016
b6f4535
Fix tests for Rails5
Jul 5, 2016
da36952
Revert "Fix warning"
Jul 5, 2016
b69e05a
Reduce Rails versions range in gemspec
Jul 5, 2016
6ec2f5f
Becareful of module namespace
Jul 5, 2016
612d09d
Add comment
Jul 10, 2016
c1cf72e
ActionForm should not depend on SimpleForm (only for tests)
Jul 10, 2016
c4382c0
Fix CodeClimate error
Jan 18, 2017
be5c214
Test with latest Ruby version
Jan 18, 2017
1ce4cdd
Fix CodeClimate reporter
n-rodriguez Mar 24, 2017
52afb96
Test with latest Ruby version
n-rodriguez Mar 24, 2017
b6376ac
Test with latest Ruby versions
n-rodriguez Apr 2, 2017
1860a35
Test with maintained versions of Rails
Apr 28, 2017
3fd79a7
Merge pull request #1 from jbox-web/master
willbryant May 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/active_form/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ def save
end
end

def save!
save or raise ActiveRecord::RecordInvalid.new(self)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK || syntax if prefered over or

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kirs is right in the syntax. But overall this is a no go for me because we're not targeting Active Record as the Rails integration point, but Active Model.
A record invalid or form invalid error using the Active Form namespace would be fine for me.

Kasper

Den 25/11/2014 kl. 22.17 skrev Kir Shatrov [email protected]:

In lib/active_form/base.rb:

@@ -42,6 +42,10 @@ def save
end
end

  • def save!
  •  save or raise ActiveRecord::RecordInvalid.new(self)
    
    AFAIK || syntax if prefered over or


Reply to this email directly or view it on GitHub.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're not targeting Active Record as the Rails integration point, but Active Model.
A record invalid or form invalid error using the Active Form namespace would be fine for me.

Good point, I totally agree.

end

def valid?
super
model.valid?
Expand Down Expand Up @@ -155,4 +159,4 @@ def collect_errors_from(validatable_object)
end
end

end
end