Hi Artur!

Thanks! Good catch! This is indeed confusing. I think the intention of 
<tt>save!</tt> is to throw an exception if validation fails, while 
<tt>save</tt>  "only" returns false if it can't persist the record.

I would take one of the following actions to fix this:
1. Update the docs of <tt>save!</tt> so they aren't confusing anymore or
2. Make <tt>save!</tt> run always validations, although validate: false is 
provided.

I would like someone of the core team tell use which direction they want to 
take with this.

El domingo, 11 de febrero de 2018, 4:19:24 (UTC+1), 
artur.b...@eestiinternet.ee escribió:
>
> It seems passing `validate: false` to `ActiveRecord::Base#save!` bypasses 
> validation, however doc states that:
>
>  With <tt>save!</tt> validations always run.
>
>
>
> https://github.com/rails/rails/blob/5d1402a1011f58b405e42007d3ceed4e122d273e/activerecord/lib/active_record/persistence.rb#L130
>
> Isn't it confusing? Perhaps it's worth triggering some check for this case?
>
> I am using Rails v4.2.5.2, but it could also apply to newest versions.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to