Ruby on Rails Info Bits
Generate controller and actions in Rails
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 ReadingNo route matches [PATCH] "/images"
"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 ReadingAdd migration with rails
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 ReadingHow to create model in Rails?
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 ReadingChange field name in Rails
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 ReadingeCommerce application with Rails
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 ReadingFree Bootstrap eCommerce templates for Rails application
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:
Continue ReadingGenerate Static Pages in Rails
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 ReadingServing Fonts with Rails Application
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 ReadingSetting Vendor Assets Precompile in Rails 4
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 ReadingServing images via CSS in Rails
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 ReadingLearn to include vendor css/js files in Rails 4
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 ReadingPreparing Test Database
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 ReadingMaterial Design
Introduction into Material Design >
Material Design with AngularJS >
Google…
Continue ReadingBinding ActiveRecord to Drop Down box
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 ReadingNoMethodError in StatusesController index
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 ReadingRemoving deleted files form Git
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 ReadingGetting Controller specific CSS and JavaScript Assets
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 ReadingUse IRB to load rails application into console
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 Readingbyebug is default debugger in Rails
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 ReadingNot forgetting before_action in Rails
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 ReadingQuick way to adding classes to Ruby links tags
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