Category Archives: Ruby on Rails
Issues with thinking sphinx
I recently faced some issues with thinking sphinx which sharing here so that it helps others. Has many association not working: I had a model named User which has many tracks and the very basic index definition is as follows: ThinkingSphinx::Index.define :track, :with => :active_record do indexes title indexes [artist.first_name, artist.last_name], :as => :artist_name, :sortable…
Securing secret token by generating new token dynamically
Many of us already know the reason to omit pushing secret token into version repository to secure the application. Attacker can take the secret token and re-generate valid cookies for your applications or check out what other users have inside their account. The solution is to: Generate manual key Not push the token into version…
ActionView::Template::Error Couldn’t find file ‘jquery-ui’ with Rails 3.2
Today, I have start working after 6 months with one of my existing Ruby on Rails application and found the mentioned error. And then found, jquery-rails removed the jQuery UI and recommended to use jquery-ui-rails or downgrade the gem version. To use latest version:Add jQuery UI in to the application.js: //= require jquery.ui.all Add jQuery…
Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)
This error may occur to run older Rails application for conflicting with rubygems version. After a long googling I’ve come out in to following three solutions: Using Bundler.:Click here if you are interested to see the solution. Changing rubygems version: Downgrade the rubygems to an earlier version using gem update –system {version} Add “require ‘thread’”…
Render HTML file in Rails using Nokogiri
You may need to render static HTML template file from a controller action without modifying anything in to file. And, may need to replace some content during render. A template may contain relative path for css, image etc. which may raise an exception as rails may not route that automatically. At that case you have…
Creating authentication from scratch in Rails 3.1
There are some popular authentication libraries like devise, Authlogic, Restful Authentication, Clearance in Ruby on Rails. But, you can implement of your own as well. Here, I’m explaining few simple steps to create your own authentication system in Rails 3.1. First, Create Run following commands from command prompt and then copy the codes in the…
Rename rails3 application
Just published new version of rename gem with following changes: Sanitize new name Search/Replace module name in all files under root and config Change session key Change directory name InstallationAdd this line to your application’s Gemfile: gem ‘rename’ Uses rails g rename:app_to NewNamerails g rename:app_to “New-Name”
Document management using jQuery
Just added a prototype site of to manage document using Ruby on Rails: Gems Uses jQuery-File-Upload CarrierWave Fog Twitter Bootstrap Haml Simple Form Rspec factory_girl Click here to contribute/checkout.
Undefined local variable or method `version_requirements’ for …
I was getting the error while installing an older rails application. After googling I’ve got the solution from a discussion thread to add following block in right before the initialization in to config/environment.rb and worked for me. if Gem::VERSION >= “1.3.6” module Rails class GemDependency def requirement r = super (r == Gem::Requirement.default) ? nil…
How to rename Rails3 application
A Rails3 application name are using as a Ruby name space for entire application and throughout the project tree as well. So, If anyone later decide to change the project name, then have to replace the name in the following files: Rakefileconfig.ruconfig/routes.rbconfig/application.rbconfig/environment.rbconfig/environments/development.rbconfig/environments/test.rbconfig/environments/production.rbinitializers/secret_token.rbinitializers/session_store.rb You can run following command in your project root, to find out the…