Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

save_whats_valid

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

save_whats_valid

  • 0.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Save What's Valid

Rails' default update_attributes behavior is that when any validation fails, none of the data gets saved. However, in some instances this is not the most ideal behavior. If you import partial data which users then have the task of completing, not saving partially completed forms can create a really negative user experience and decrease overall completion (or conversion) rates.

For example, some users complained when their incomplete changes didn't stick bceause they had intended to send the remainder of the form to a colleague to complete the rest.

This gem encapsulates the logic I've used to ensure that partially completed forms still persist.

Usage

class Person < ActiveRecord::Base

  # Include the module.
  include SaveWhatsValid

  # These are the attributes available on the model.
  attr_accessible :age, :description, :first_name, :last_name, :middle_initial

  # These two attributes are required.
  validates_presence_of :first_name
  validates_presence_of :last_name

  # These are the attributes we want to save any valid value for.
  save_whats_valid :age, :description, :first_name, :last_name

end

FAQs

Package last updated on 14 May 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc