simple-image-uploader 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +41 -3
- data/lib/simple-image-uploader/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# simple-image-uploader
|
2
2
|
|
3
|
-
|
3
|
+
simple-image-uploader is a Rails 3 generator that creates a small scaffold class called Image. It enables image upload feature to your web app at no time.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,7 +18,45 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
After adding gem 'simple-image-uploader' to your Gemfile.
|
22
|
+
|
23
|
+
You should go back to your terminal and type:
|
24
|
+
|
25
|
+
rails g simple_image_uploader
|
26
|
+
|
27
|
+
The gem will generate all the files, routes and add the gems needed for image upload.
|
28
|
+
|
29
|
+
After, you can run
|
30
|
+
|
31
|
+
rails s
|
32
|
+
|
33
|
+
Then you can access the following URL:
|
34
|
+
|
35
|
+
http://localhost:3000/images
|
36
|
+
|
37
|
+
Use the Image class to see how you can add the image upload to your existing app.
|
38
|
+
|
39
|
+
For example, if you have a Post class where people can upload images for each post, you should add the following code:
|
40
|
+
|
41
|
+
In the models/post.rb
|
42
|
+
|
43
|
+
has_many :images
|
44
|
+
|
45
|
+
In the models/image.rb
|
46
|
+
|
47
|
+
belongs_to :post
|
48
|
+
|
49
|
+
And run
|
50
|
+
|
51
|
+
rails g migration add_post_id_to_images post_id:integer
|
52
|
+
|
53
|
+
rake db:migrate
|
54
|
+
|
55
|
+
rails s
|
56
|
+
|
57
|
+
The secret is to link image model to each of your other models that need image upload. For each new link you can either create has_many or has_and_belongs_to relationships.
|
58
|
+
|
59
|
+
|
22
60
|
|
23
61
|
## Contributing
|
24
62
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-image-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -39,7 +39,7 @@ files:
|
|
39
39
|
- LICENSE
|
40
40
|
- Rakefile
|
41
41
|
- README.md
|
42
|
-
homepage:
|
42
|
+
homepage: https://github.com/designium/simple-image-uploader
|
43
43
|
licenses: []
|
44
44
|
post_install_message:
|
45
45
|
rdoc_options: []
|