Strange error in rails – missing helper

The problem seems to have been introduced in the latest version of ruby, ruby 2.2.0. Try this experiment: in rails console/or irb: [1] pry(main)>File.expand_path (“./”) => “/users/xxxx/Sites/xxxx” and in the terminal window: ]$ pwd /users/xxxx/sites/xxxx See the different case? If you get that, then deep in the bowels of active support a regex goes south. … Read more

Rails: How to use i18n with Rails 4 enums

Starting from Rails 5, all models will inherit from ApplicationRecord. class User < ApplicationRecord enum status: [:active, :pending, :archived] end I use this superclass to implement a generic solution for translating enums: class ApplicationRecord < ActiveRecord::Base self.abstract_class = true def self.human_enum_name(enum_name, enum_value) I18n.t(“activerecord.attributes.#{model_name.i18n_key}.#{enum_name.to_s.pluralize}.#{enum_value}”) end end Then I add the translations in my .yml file: en: … Read more

Rails 4 multiple image or file upload using carrierwave

This is solution to upload multiple images using carrierwave in rails 4 from scratch Or you can find working demo : Multiple Attachment Rails 4 To do just follow these steps. rails new multiple_image_upload_carrierwave In gem file gem ‘carrierwave’ bundle install rails generate uploader Avatar Create post scaffold rails generate scaffold post title:string Create post_attachment … Read more