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 Rails 4.2 compatibility #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andypike
Copy link

I needed to add a few methods to allow this gem to work with Rails 4.2
and simple_form 3.1. These methods were as follows:

Attribute#number? - returns true if the attribute type is numerical,
otherwise returns false.

Attribute#limit - returns the database column size limit which
simple_form uses to set maxlength/size attributes on the input controls
if there are no length validations. I return nil here so no html
attributes are added. If you add length validations then these do still
result in html attributes for length being added.

SimpleFormObject#has_attribute? - returns true if the passed attribute
has been declared for the form object otherwise returns false.

In addition to these changes I have also added a new class method for
overriding the model name used (for routing). Now you can do this:

class FooForm
  include SimpleFormObject

  route_as :bar
end

This will result in the form using the path helpers bars_path rather
than foos_path etc.

I needed to add a few methods to allow this gem to work with Rails 4.2
and simple_form 3.1. These methods were as follows:

Attribute#number? - returns true if the attribute type is numerical,
otherwise returns false.

Attribute#limit - returns the database column size limit which
simple_form uses to set maxlength/size attributes on the input controls
if there are no length validations. I return nil here so no html
attributes are added. If you add length validations then these do still
result in html attributes for length being added.

SimpleFormObject#has_attribute? - returns true if the passed attribute
has been declared for the form object otherwise returns false.

In addition to these changes I have also added a new class method for
over riding the model name used (for routing). Now you can do this:

```
class FooForm
  route_as :bar
end
```

This will result in the form using the path helpers bars_path rather
than foos_path etc.
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.

1 participant