gem Blogs
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
Kiprosh is now part of LawLytics
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
We recently upgraded one of our app to Ruby 2.2.2 Bundle installed failed ...... crying about well known issue of Error installing gem with native extension, but this time for Gem json -v 1.8.3 Detailed error shows Fetching: json-1.8.3.gem (100%) Building native extensions. This could take a while... ERROR: Error installing json: ERROR: Failed to build gem native extension. /usr/local/rvm/rubies/ruby-2.2.2/bin/ruby -r ./siteconf20151209-13741-vqcxt1.rb extconf.rb creating Makefile make "DESTDIR=" clean make "DESTDIR=" compiling generator.c linking shared-object json/ext/generator.so /usr/
On our Mac OSx, if we upgrade to latest Ruby 2.1.5 (or even 2.1.2) then there are high chances that we will face issues installing nokogiri gem. We might face errors like: ERROR: Failed to build gem native extension. Following are the steps to resolve these issues on Mac OSx Install library libxml2 using brew. brew install libxml2 Read complete error dump on console while doing bundle or bundle install. We will notice that there are useful tips to fix this on our OS, for example for building Nokogiri with a packaged version of libxml2-2.9.
In our current app, there was a requirement to have a nice editor which will provide the basic functionalities like bold,italic and also image upload. We decided to use redactor-rails gem Github-Documentation-Link(Github Doc) . So i took following steps: In Gemfile i included: gem 'redactor-rails' Then for image uploading and storing i included two more gems as: gem 'carrierwave' gem 'mini_magik' Bundle it. rails generate redactor:install rails generate redactor:config In application.js //= require redactor-rails In active_admin.scss on the top include: *= require redactor-rails In ActiveAdmin model i wrote: f.input :name, input_html: {class: 'redactor'}
This post is an extension of article. I added further customization to check if user has active chargify_subscription and then only proceed to login otherwise show custom message instead of default devise message. Here is what I did (2 step process). In our user model (specifically user_extensions) override devise method active_for_authentication as follows def active_for_authentication? super && locked? && active_subscription? end Calling super first is very important here, to have devise perform all its regular checks first and then upon success we can proceed to add our custom checks. locked? is
Lately, I was working on a project where I found an issue that emails sent using ActionMailer were not applying css styles to the html elements of the email. On adding style tag in the email view files, I was able to view stylings on thunderbird mail and ymail but still I was unable to view css stylings for emails in gmail. On furthur investigating the issue, I found that gmail requires inline stylings to be applied to the email templates. I found some gems which could fix this problem by converting external css to inline css. I tried the
PRY GEM Pry is a powerful alternative to the standard IRB shell for Ruby. It is a REPL (it reads, evaluates, prints, loops). Pry’s advantages over irb are Pry adds additional features such as syntax-highlighting, managing history, Live help system etc. CONFIGURE YOUR RAILS APP TO USE PRY INSTEAD OF IRB: Add this line to your gemfile: gem 'pry-rails', :group => :development then run: bundle install you can go ahead and load the console normally using: rails console Once you have the gem installed, you can enter into a session with pry, by just typing pry in your Terminal. pry
ActiveSkin gem provides an easy way to customize Active Admin CSS depending upon your website's color scheme in just few minutes. Steps: 1/ Add to your Gemfile: gem 'active_skin' 2/ Run: bundle install 3/ Add to active_admin.css.scss: //Add the Website's logo. This is displayed on the top-left corner of the page. $skinLogo: url("logo.png") no-repeat 0 0; //This color is applied to buttons, drop-down lists etc. in the AA UI $skinActiveColor: #05B6C7; //Applied to the main header of Active Admin $skinHeaderBck: #000000; //Applied to the header of AA filters. $panelHeaderBck: #000000; @import "active_skin"; Sample
Apipie-rails is a DSL and Rails engine for documenting you RESTful API. Instead of traditional use of #comments, Apipie lets you "describe the code by code". This brings advantages like: It uses ruby syntax Reusable doc for other purposes (Best for validations) Easier to extend and maintain apipie-rails gem owner has documented it in very nice way with examples. Refer [Github Documentaion(github doc)][1] Path to documentation: The documentation is available right in your app (by default under "/apipie" path.) Also you can provide your own path using initializers. For more information refer [here(config
Using as Gem: gem 'gettext_i18n_rails' Using as plugin: gem 'fast_gettext', '>=0.4.8' Add "gettext" if you want to find translations or build .mo files Add "ruby_parser" if you want to find translations inside haml/slim files gem 'gettext', '>=3.0.2', :require => false, :group => :development gem 'ruby_parser', :require => false, :group => :development Rakes: rake gettext:add_language[XX] This will also create the locale directory (where the translations are being stored) where XX is the ISO 639-1 2-letter code for the language you
MetricFu is an aggregator of several static code analysis tools for Ruby. It displays code metrics from Flog, Flay, Saikuro, Churn, Reek, Roodi, Code Statistics, and Rails Best Practices (and optionally code coverage with RCov). With MetricFu, you get a combined HTML report of all the metrics. Installing gem: gem install metric_fu Running follwing command from your application root. metric_fu This will generate reports in metric_fu's output directory (tmp/metric_fu/output). By default, metric_fu will use the built-in html formatter to generate HTML reports for each metric with pretty graphs and output can be seen