Skip to content

Instantly share code, notes, and snippets.

@plapier
Created November 16, 2012 17:02
Show Gist options
  • Select an option

  • Save plapier/4088995 to your computer and use it in GitHub Desktop.

Select an option

Save plapier/4088995 to your computer and use it in GitHub Desktop.

Revisions

  1. Phil LaPier revised this gist Nov 16, 2012. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,19 @@

    rails generate controller <controller name> <action>

    ####Change layout for controller
    ####Change layout for entire Controller

    render :layout => 'special_layout'
    class ProductsController < ApplicationController
    layout "inventory"
    end

    ####Change layout for Controller ACTION

    class ProductsController < ApplicationController
    def index
    render :layout => 'special_layout'
    end
    end

    #HTML.ERB

  2. Phil LaPier created this gist Nov 16, 2012.
    49 changes: 49 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    #Rails

    ####Generate a controller and action

    rails generate controller <controller name> <action>

    ####Change layout for controller

    render :layout => 'special_layout'

    #HTML.ERB

    ####Create a link

    <%= link_to “Go Home”, root_path %>

    ####Wrap in a link

    <%= link_to root_path, :id => "root" do %>
    <img />
    <% end %>

    ####Repeat elements

    <% 3.times do %>
    <li></li>
    <% end %>

    ####Render a partial

    <%= render 'sidebar' %>

    ####Insert and image using the asset pipeline

    <%= image_tag("foo.png") %>

    ####Linking Javascript assets

    <%= javascript_include_tag "main", "columns" %>

    ####Linking Stylesheet assets

    <%= stylesheet_link_tag "main", "columns" %>

    #CSS

    ####CSS Image Assets

    background: image_url("image.png");