Rails routes can be customized to include your own parameters inside it. Lets first understand how named routes works: Adding dynamic parameters to routes Here exact parameters are matched to route and presence of each parameter is mandatory in order to construct urls. If blank parameter is supplied then it...

puts converts ruby object into string by invoking to_s method on object. The default to_s prints the object’s class and an encoding of the object id. In order to print human readable form of object use inspect ruby locs = Location.find_by_sql('select * from locations') Location Load (0.5ms) select * from...

CSV (comma separated values) files are frequently used to import/export data. In rails 3, FasterCSV comes as default and below is the way to upload csv files inside rails applications. The code below will also show you how to generate csv in memory, parse on csv data, skip header, iterate...

Previous post explains on mongoid document array field and rails form implementation Below example shows rails form integration of array field of embedded mongoid document Lets consider scenario that student embeds one family who has many assets ```ruby class Student include Mongoid::Document field :name field :phone embeds_one :family validates_associated :family...

Mongoid document supports array field. Mongoid array field is a ruby array but it becomes quite complex to manage array field in rails forms. I didn’t find anything matching on google as well on stackoverflow hence decided to dig into rails form helpers (form_for, fields_for). Finally i am pleased to...

twitter-bootstrap is pluggable css suit provided by twitter. To know more about how to get started on it click here. Below post will help you out in getting started bootstrap css with rails app. One need to add below files to helpers directory. MainForm can be used as base version...

How to get collection of models inside your application. Certainly there are many ways to do it. Lets have a look at different ways starting from worst - Get table names inside database and then iterating over to get model name ```ruby @models = ActiveRecord::Base.connection.tables.collect{|t| t.underscore.singularize.camelize} #=> [“AdhearsionAudit”, “AudioLog”, “AuditDetail”,”TinyPrint”,...

Stripe is simple website payment solution and its very easy to easy setup. It currently supports only in US and seems to be very popular compared to other payment gateways because of its api & pricing Stripe API provides - charge (regular payments) subscription (recurring payments) managing customers (via stripe_customer_token)...

rails-uri module provides us with url manipulation methods Parse string url url = URI.parse('http://funonrails.com/categories/rails-3') url.host #=> "http://funonrails.com" url.port #=> 80 URL with Basic Authentication url = URI.parse('http://sandip:2121@funonrails.com/categories/rails-3') url.user #=> "sandip" url.password #=> "2121" Extracting urls form string paragraph URI.extract('http://funonrails.com is rails blog authored by http://sandipransing.github.com contact mailto://sandip@funonrails.com') #=> ["http://funonrails.com", "http://sandipransing.github.com",...

Paypal standard website payment service allows online payment transactions for websites. Before implementing payments inside rails app needs to have following things in place - Register Paypal sandbox account Paypal Merchant account api credentials i.e. login, password, signature, application_id Paypal Buyer account creds to test payments Bundle Install # Gemfile...