Skip to content

Instantly share code, notes, and snippets.

View dhamkur's full-sized avatar
🏠
Working from home

dhamkur dhamkur

🏠
Working from home
  • VirtualSpirit
  • Indonesia
View GitHub Profile
class ImageUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
process :tags => ['post_picture']
version :standard do
process :resize_to_fill => [100, 150, :north]
end
version :article do
@dhamkur
dhamkur / application_helper.rb
Created January 20, 2019 06:58
Ruby on Rails. Class "active" for menu items based on Path or Controller and Action names
module ApplicationHelper
def active_for(options = {})
name_of_controller = options[:controller] || nil
name_of_action = options[:action] || nil
request_path = options[:path] || nil
if request_path.nil?
if (name_of_action.nil? or name_of_action == action_name) and
name_of_controller == controller_name
'active'