simple_form_object 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a69baf840092290a6fa0f0a87af33bbab2755dac
4
- data.tar.gz: a751158509221fbd5a1dd3b360d7302da29739fa
3
+ metadata.gz: 2c5b1bb8877957e9dece06a0ea28f2eddb48c744
4
+ data.tar.gz: b1d5870ddc177dad61b1ec5f313f37a378cb2565
5
5
  SHA512:
6
- metadata.gz: d81bc3300e0d973e84162f87264c29c6169375940d0e2f126a4a82a1504439dcde181b645075f1678de26bf3e1075caed2542aa081ad7e511f2afff1ffa06387
7
- data.tar.gz: 7ec09e6a3d97b8ad39df15e2d42a22d38f9443502b7f1f34f203de29221e78151bd147bdd99916f9319b4a31d2a16fce73e8bc28bfb96a6d62a61922c340ceac
6
+ metadata.gz: 5cbbbde1b4d58ed0374267535412fb76375e172dd2ec02f16692357dab90844a2cc697a676b16d85235365fa0075c9c70ca80331dc115db70175b9ec326bb389
7
+ data.tar.gz: 97b625f72a2bdec29e3e97d2aabeb3364d6a33e47d0f1751fdd5e1015ed0d6f6d4a06dfc7f39ffab8c4a76847e62d28b7d4eb7eac8f04c9546ccd83eafa411cf
data/README.md CHANGED
@@ -1,28 +1,72 @@
1
- # SimpleFormObjects
1
+ # SimpleFormObject
2
2
 
3
- TODO: Write a gem description
3
+ Allows you to make really simple non-persisted form objects or models.
4
+
5
+ **Only suitable for Rails 4 applications.**
6
+
7
+ You don't need to remember to:
8
+
9
+ 1. `include ActiveModel::Model`
10
+ 2. Set the class `model_name` so Rails url generation works for forms.
11
+
12
+ It gives you:
13
+
14
+ 1. Default values for your form attributes.
15
+ 2. Integration with simple_form so you don't need to specify the field type on the form.
16
+ 3. Thanks to `ActiveModel::Model` you can use standard Rails validations on your attributes.
4
17
 
5
18
  ## Installation
6
19
 
7
20
  Add this line to your application's Gemfile:
8
21
 
9
- gem 'simple_form_objects'
22
+ ```ruby
23
+ gem 'simple_form_object'
24
+ ```
10
25
 
11
26
  And then execute:
12
27
 
13
28
  $ bundle
14
29
 
15
- Or install it yourself as:
30
+ ## Usage
16
31
 
17
- $ gem install simple_form_objects
32
+ Create a form class. I like to put them inside `app/forms/`. If you
33
+ prefer to create models then that will work too.
18
34
 
19
- ## Usage
35
+ ```ruby
36
+ class PostForm
37
+ include SimpleFormObject
38
+
39
+ attribute :body, :text
40
+ attribute :title, :string
41
+ attribute :publish_date, :datetime, default: Time.now
42
+
43
+ validates_presence_of :body
44
+ validates_presence_of :title
45
+ end
46
+ ```
47
+
48
+ `SimpleFormObject` includes `ActiveModel::Model` so you don't need to.
49
+ It also intelligently sets the `model_name` on the class so that Rails
50
+ routing works as expected. As an example:
51
+
52
+ ```erb
53
+ <%= simple_form_for @post_form do |f| %>
54
+ <%= f.input :title # renders a simple string input %>
55
+ <%= f.input :body # renders a textarea %>
56
+ <%= f.input :publish_date # renders a datetime select html element %>
57
+ <% end %>
58
+ ```
59
+
60
+ Will create a HTML form which will `POST` to `posts_path`.
61
+
62
+ ## Todo:
20
63
 
21
- TODO: Write usage instructions here
64
+ 1. Automatically add good validations for types.
65
+ 2. It's tested in `spec` but better tests wouldn't hurt.
22
66
 
23
67
  ## Contributing
24
68
 
25
- 1. Fork it ( http://github.com/<my-github-username>/simple_form_objects/fork )
69
+ 1. Fork it ( http://github.com/reInteractive-open/simple_form_objects/fork )
26
70
  2. Create your feature branch (`git checkout -b my-new-feature`)
27
71
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
72
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,3 +1,3 @@
1
1
  module SimpleFormObject
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonard Garvey