Ruby on Rails Info Bits

Generate controller and actions in Rails

  • Monday, October 5, 2015 8:32 PM

Rails controller generation is done with the help of Rake command line tool. Actions are added along with the controller. Action can be added directly into controller .rb file after initial controlle…

Continue Reading

No route matches [PATCH] "/images"

  • Monday, October 5, 2015 8:13 PM

"No route matches [PATCH] "/images"" error message can occur when developer specifies target URL in the code versus letting Rails framework to pick one based on routing rules set in the routes.rb fi…

Continue Reading

Add migration with rails

  • Monday, October 5, 2015 8:08 PM

Adding empty migrations is often used task when working on your database model. Migrations are used to apply sequantually database changes to the database. 

> rails generate migration AddN…

Continue Reading

How to create model in Rails?

  • Monday, October 5, 2015 7:54 PM

Rails uses rake command line tool for creation of models. The following example does just that

> rails generate model Product title:string description:text

This command line will generate migr…

Continue Reading

Change field name in Rails

  • Monday, October 5, 2015 7:50 PM

Change of column name or attribute rename in your database using Rails is possible with the help of Rails migration files. Here is an example that does just that

class FixColumnNameForImagesProduct…

Continue Reading

eCommerce application with Rails

  • Monday, October 5, 2015 7:11 PM

Rails community produced several ecommerce projects worth checking. Railcast is known video tutorial site provides a list of video tutorials for each ecommerce project developed in Rails

Continue Reading

Free Bootstrap eCommerce templates for Rails application

  • Monday, October 5, 2015 7:01 PM

There are several ways you can get bootstrap template for your ecommerce application you are trying to develop. The good source of templates available for you to use is listed here:

by T…

Continue Reading

Generate Static Pages in Rails

  • Monday, October 5, 2015 6:48 PM

Often times you'll need to generate static pages in your Rails application. These pages don't require to have object classes of models to relay on for data. These pages may simply be 404 Error pages …

Continue Reading

Serving Fonts with Rails Application

  • Monday, October 5, 2015 6:31 PM

Rails application allows you to add custom fonts to it via application.css.scss file. All you need to do in order to accomplish it is to add @font-face with links pointing to your font file. Please n…

Continue Reading

Setting Vendor Assets Precompile in Rails 4

  • Monday, October 5, 2015 6:24 PM

Often times you'll need to use some kind of vendor specific files for your Ruby on Rails project. These files can be part of CSS/JavaScript template you use for your project. They can't be stored in …

Continue Reading

Serving images via CSS in Rails

  • Monday, October 5, 2015 6:11 PM

Ruby on Rails is versatile enough to help you access and service image from your css files. It relies on Rails Asset Pipeline helpers.

You can reference your images within CSS files via two help…

Continue Reading

Learn to include vendor css/js files in Rails 4

  • Monday, October 5, 2015 5:55 PM

In order to include vendor assets such as CSS/JavaScript files you need to utilize Ruby on Rails Asset Pipeline. In order to implement this inclusion, you need to add file name with the require and/o…

Continue Reading

Preparing Test Database

  • Thursday, September 10, 2015 8:17 PM

In order to start testing your application you need to make sure test environment is set up. This is done in Ruby on Rails by executing the following rake command

> rake db:test:prepare

Continue Reading

Material Design

  • Thursday, September 10, 2015 7:08 PM

Introduction into Material Design > 

Material Design with AngularJS >

Google…

Continue Reading

Binding ActiveRecord to Drop Down box

  • Wednesday, September 9, 2015 4:21 PM

You can use collection_select in order to bind to HTML drop down box for possible selections of your form. Please make sure all of the proper belongs_to and has_many relationship…

Continue Reading

NoMethodError in StatusesController index

  • Wednesday, September 9, 2015 2:36 PM

You may run into undefined method `attr_accessible'  error message when adding restrictions on what attributes of the object can or cannot be accessed. This error is due to deprecation of …

Continue Reading

Removing deleted files form Git

  • Wednesday, September 9, 2015 2:05 PM

In order to remove locally deleted or renamed files from the local git repository so that publishing it to git can clean up remote git repository can be accomplished by running git rm command as spec…

Continue Reading

Getting Controller specific CSS and JavaScript Assets

  • Wednesday, September 9, 2015 1:45 PM

You can run into problems of assets inclusion for specific controllers after generating scaffolding or generating controllers in Rails. This is the default behavior of Rails 4 and below. You can elim…

Continue Reading

Use IRB to load rails application into console

  • Tuesday, September 8, 2015 9:31 PM

Rails Console is useful for loading Rails Application into your console also known as IRB. You can exit from IRB by entering exit command line and exist back out of IRB console.

Useful link: 

Continue Reading

byebug is default debugger in Rails

  • Thursday, September 3, 2015 6:58 PM

Rails framework now relies on Byebug for all your debugging needs and it is advisable to switch form other default debugging gem when you start working with Riuby on Rails. 

# Call 'byebug' an…

Continue Reading

Not forgetting before_action in Rails

  • Thursday, September 3, 2015 6:27 PM

There is a new way of setting up your arguments in the Rails framework version 4.2.4. It relies on the set_post action inside your controller.

# Use callbacks to share common setup or constrai…

Continue Reading

Quick way to adding classes to Ruby links tags

  • Thursday, September 3, 2015 6:20 PM

 In order to add classes to Ruby on Rails links, we need to enclose it in curly brackets as shown in the example below

<%= link_to "adding new posts", new_post_path,   { :class=>"bt…

Continue Reading

Featured pages

Ruby

Set of Ruby Object Oriented Programming Language tutorials that cover such topics as Ruby strings, …

Rails

Rails Framework tutorial teaches you how to utilize de facto framework of choice for Ruby developme…

Ruby Duck Typing

“If an object quacks like a duck just go ahead and treat it as a duck” – this fun…

Regular Expressions

Ruby uses the =~ operator to check any given string against regular expression. For example, a stri…

Credit Card Number

Every last digit of any credit card is a check sum digit that is determined by all digits in front …

Ruby Arrays

Ruby Programming Language has built in support for Arrays. Arrays help you define some of the compl…

Ruby Hashes

Hashes are very similar to arrays in Ruby and hashes interface is similar to Ruby array interface. …

Ruby Code Block

Ruby is very unique language when it comes to code blocks. You can simply pass a code block to a me…