Thursday, 5 January 2017

select_tag with options_for_select

An example of using options_for_select with select_tag

<%=select_tag 'category_id', options_for_select(Category.all.collect{ |u| [u.name, u.id] })
 %>

This would generate something like:
<select id="user_id" name="user_id">
  <option value="1">Brad</option>
  <option value="2">Angie</option>
  <option value="3">Jenny</option>
</select>



Monday, 2 January 2017

Images Version end size

1:- Create new gem - gem 'mini-magick'

2. Uploader

  class MyUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
version :thumb do
    process resize_to_fill: [200,200]
  end


 version :medium do
    process resize_to_fill: [400,400]
  end
version :project do
    process :resize_to_fill => [275, 180]
  end

  version :comment do
    process :resize_to_fill => [580, 0]
  end  

  version :projectimg do
    process resize_to_fit: [275,180]
    process :convert => :jpg   
  end

  version :featuredmd do
    process :resize_to_fill => [585, 350]
  end

  version :featuredsm do
    process :resize_to_fill => [400, 350]
  end

  version :topicbanner do
    process :resize_to_fill => [800, 350]
  end 

  version :topicmd do
    process :resize_to_fill => [450, 350]
  end 

  version :topiclg do
    process :resize_to_fill => [650, 350]
  end 
  version :userbanner do
    process :resize_to_fill => [800, 350]
  end

3. Version create: upload -index.erb
  image.url(:version name)