Skip to content

Instantly share code, notes, and snippets.

@plapier

plapier/gist:4088995

Created Nov 16, 2012
Embed
What would you like to do?
Rails for Designers Cheat Sheet

#Rails

####Generate a controller and action

rails generate controller <controller name> <action>

####Change layout for entire Controller

class ProductsController < ApplicationController
  layout "inventory"
end

####Change layout for Controller ACTION

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

#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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment