The meaning of `*` when using as a param(not like *arg, just *)
ruby, ruby-on-rails
Solution
In this specific case, save doesn't take any arguments. That's what happens with a naked splat. But, as you may be aware, calling save on an `ActiveRecord` model accepts options because this method gets overridden by `ActiveRecord::Validations` here:
https://github.com/rails/rails/blob/v3.1.3/activerecord/lib/active_record/validations.rb#L47
# The validation process on save can be skipped by passing <tt>:validate => false</tt>. The regular Base#save method is
# replaced with this when the validations module is mixed in, which it is by default.
def save(options={})
perform_validations(options) ? super : false
end
Problem
When I was reading Rails code, I found this ``` def save(*) create_or_update || raise(RecordNotSaved) end ``` What does the `*` do? :O I know what happens when we use it like `*args`, but in this case, it's just plain `*`. ref https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L119