All 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.
public_activity is the best gem for easy activity tracking of models and easy to integrate in your rails application. links: Github-doc, Demo STEPS: In your gemfile: gem 'public_activity' Generate migration for activities and migrate the database (in your Rails project): rails g public_activity:migration rake db:migrate Include PublicActivity::Model and add tracked to the model you want to keep track of: class Answer now, by default create/update/destroy activities are recorded in activities table.(basic CRUD actions) Displaying activities: (see more details) controller: def index @activities = PublicActivity::Activity.all end views: public_activity looks for
Problem case to solve : Crawl any given site(url), scrape each page uniquely for content from given selector or Xpath Available options for Crawling and Scraping : With [libxml2][1] [Nokogiri][2] is one of the fastest HTML/XML parser. Almost all of the scraping tools written in Ruby such as Mechanize, Wombat, Anemone, etc. uses Nokogiri as there base DSL for sraping. [Mechanize][3] - Is a beast in this category. It efficiently uses Nokogiri for HTML scrapping. Do see Abi's post on [Automating browser navigation's through Script][4] [Wombat][5] takes the scraping term to a next higher level,
You can use a single gem 'roo' for reading all types of file, instead of rubyXL, spreadsheet etc. multiple gems for different files(.xls, .xlsx). You can check [here railscasts][1] for importing csv and excel import in ruby 1.9.3. But this code snippet is not working with Ruby 2.0. As [this episode][2] used gem 'roo' for reading files and gem 'roo' has been updated for rails 4.0. So you need to do some code changes to work [it][3] with rails 4.0 Changes are: In Method: self.open_spreadsheet(file) Csv.new(file.
Most of the times we look up to pass extra params in url. This post will give an overview of possible query string formation but in rails way. For this, we know the common syntax for query string is "/controller/action?name='A'&id=1", where multiple params are separated by '&' literal. Here are the common rails ways: to_param => Returns a String, which Action Pack uses for constructing an URL to this object. i) When operated over hash, it will assignment string. For say, => {a: 1}.to_param => "a=1" ii) When
For any applications, we require many jquery and css files to be loaded on each request (i.e HTML requests). Instead, we can render all the files at once and reuse these files over-and-over again to save our page-load time. To serve this purpose, we have several gems and one of them is rack-pjax. rack-pjax uses ajax and pushState to deliver a fast browsing experience with real permalinks, page titles, and a working back button. pjax works by grabbing html from your server via ajax and replacing the content of a container on your page with the ajax'd html. It
Pagination in Rails Application: Kaminari and will_paginate are the mostly used and the best gems for pagination. Also if you want to go for pagination on scroll with link for ex. “Load More Result” (as we have for activities in knowbuddy), then it is also easy with this gems. You can check this tutorial(Tutorial) Pagination with infinite scrolling: But if you want to have pagination as we have in facebook, without any load-more link, just display result as we scroll down through the page, then here you can make use of this plugin jquery.pageless [Github link(Github
Hello Everyone, I wanted to share few links that Swapnil shared with me in the past. All of the links were really great. So I am sharing it here. Also if possible, just take an hour to go through the links. They are really good. If you guys find any good links other than the ones I give below, please post them as comments.So that this post can help someone who needs good references for the specs in the future. https://github.com/jnicklas/capybara https://gist.github.com/zhengjia/428105 :capybara cheat sheet http://eggsonbread.com/2010/09/
In most of our apps, we probably need to execute few background tasks more often, like every 10 minutes, once a week, etc. For scheduling these jobs, we need a scheduler that can re-run these tasks on specified intervals. There are few schedulers like whenever, resque-scheduler, rufus-scheduler, etc that can do the job. However, these gems are not compatible Sidekiq and with apps deployed on Heroku. There are 2 ways to make it work on Heroku. 1/ Using Heroku Scheduler addon. Steps: i) Create sidekiq job. ii) Create a rake task that will triggers that worker. iii) In Heroku Scheduler
redactor-rails has a advantage like no need to see preview of html contents. Add gem gem 'redactor-rails' Add to your application.js: //= require redactor-rails Add to your application.css: *= require redactor-rails and in your input field need to add a class: "redactor" thats it. You can integrate carrierwave with this to save images in apFor more see documentation :https://github.com/SammyLin/redactor-rails
This gem is not something that you are going to use in project, However, This will help you to get all the cheatsheats, that will help us in getting up to speed. Setting up cheat gem gem install cheat The first command u need to try out is the sheets cheat cheat : How to use cheat gem cheat sheets : Show list of available lists in console. This will give u a list of available sheets like: git, cucumber, rspec, svn, ssh, loose_weight etc. The list is also growing continuesly How to use this, cheat git cheat cucumber If you