Tutorial by Examples

Partial templates (partials) are a way of breaking the rendering process into more manageable chunks. Partials allow you to extract pieces of code from your templates to separate files and also reuse them throughout your templates. To create a partial, create a new file that begins with an undersco...
To let rails automatically and correctly link assets (css/js/images) in most cases you want to use built in helpers. (Official documentation) Image helpers image_path This returns the path to an image asset in app/assets/images. image_path("edit.png") # => /assets/edit.png image_...
As Rails follows the MVC pattern Views are where your "templates" are for your actions. Let's say you have a controller articles_controller.rb. For this controller you would have a folder in views called app/views/articles: app |-- controllers | '-- articles_controller.rb | '-- vie...
If you ever wanted to determine the html content to be printed on a page during run time then, rails has a very good solution for that. It has something called the content_for which allows us to pass a block to a rails view. Please check the below example, Declare content_for <div> <%=...
HAML (HTML abstraction markup language) is a beautiful and elegant way to describe and design the HTML of your views. Instead of opening- and closing tags, HAML uses indentation for the structure of your pages. Basically, if something should be placed within another element, you just indent it by us...

Page 1 of 1