Sha256: b127626464f912b4f427535e2c137005cc4233c07d39d11f3878fe2e96c334d6

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

= Crimagify

Manage your model images with RMagick and CarrierWave.

== Installation
1. Add to your Gemfile: <tt>gem 'crimagify'</tt>
2. Run <tt>Bundle</tt>
3. Execute: <tt>rails generate crimagify:install</tt>
4. Run migrations: <tt>rake db:migrate</tt>
5. Run seeds: <tt>rake db:seed</tt>
----

== Implementation
Add to your routes.rb: <tt>mount Crimagify::Engine => "/crimagify", :as => "crimagify"</tt>

Add to your model:

    
    ...
    extend Crimagify::DinamicImageMethods
    has_many :crimagify_images, :as => :parent, :dependent => :destroy, :class_name => Crimagify::Image
    build_methods_images
    ...
		

Add to your controller:

    
    ...
    #For Action Create:
    if @object.save
    	Crimagify::ImageFunctions::create_new_images(@object, params)
    end
    ...

    ...
    #For Action Update:
    id @object.update_attributes(params[:object])
    	Crimagify::ImageFunctions::update_images(@object, params)
    end
    ...

Add to application.js:<tt>//= require crimagify/application</tt>


Edit the file generated for the gem: config/crimagify_versions.yml, with the specific format mantaining the same ratio for all versions in each blocks, adding models that use images:

    
    User:
        imgA:
            user:
                width: 100
                height: 100
            big:
                width: 500
                height: 500
        imgB:
            big:
                width: 800
                height: 500
            small:
                width: 400
                height: 250
    Product:
        imgA:
            big:
                width: 600
                height: 300

Add to your form view:

    
    <%= form_for(@object) do |f| %>
    ...
    <%= images_id(@object) %>
    <%= image_cropper(@object, { image_name: "imgA", ratio: :big}) %>   #The attributes "imgA" and :big or :small are defined 
    <%= image_cropper(@object, { image_name: "imgB", ratio: :small}) %> #into file config/crimagify_versions.yml generated for the gem
    ...
    <% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
crimagify-0.0.4.3 README.rdoc
crimagify-0.0.4.2 README.rdoc
crimagify-0.0.4.1 README.rdoc
crimagify-0.0.4.0 README.rdoc