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

support nil as model for reform #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 27, 2016

  1. support nil as model for reform by including NotPersisted module

    In some cases reform is just used for coercion & validation without any persistence done.
    In these cases it was advised to use nil as reform model & to mark all properties as virtual.
    
    this works fine, however fails as .persisted? is called on nil upon rendering in actionpack-3.2.22.2/lib/action_view/helpers/form_helper.rb:388
    
    ...
      as = options[:as]
        action, method = object.respond_to?(:persisted?) && object.persisted? ? [:edit, :put] : [:new, :post]
        options[:html].reverse_merge!(
          :class  => as ? "#{action}_#{as}" : dom_class(object, action),
          :id     => as ? "#{action}_#{as}" : [options[:namespace], dom_id(object, action)].compact.join("_").presence,
          :method => method
        )
     ...
    Pieter Vanmeerbeek committed Sep 27, 2016
    Configuration menu
    Copy the full SHA
    9ee261f View commit details
    Browse the repository at this point in the history