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

Conversation

leomayleomay
Copy link

No description provided.

@@ -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 notifications@github.com:

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.

@kirs
Copy link

kirs commented Nov 25, 2014

I'll be happy to merge it right after #18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants