Skip to content

Instantly share code, notes, and snippets.

@PavloConan
PavloConan / Simple HTML example
Last active February 2, 2016 13:31
Pure HTML
<ul class="example">
<li id="first"> This </li>
<li id="second"> Looks </li>
<li id="third"> Ok </li>
</ul>
%ul {:class => "example"}
%li {:id => "first"} This
%li {:id => "second"} Looks
%li {:id => "third"} Better
@PavloConan
PavloConan / Even simpler HTML.HAML example
Last active February 2, 2016 13:54
another html.haml
%ul.example
%li#first This
%li#second Looks
%li#third Best
<div class="example">
<% for @item in @shopping_list %>
<%= @item %>
<% end %>
</div>
@PavloConan
PavloConan / Html.erb to html.haml
Created February 2, 2016 14:29
html.erb -> html.haml
.example
- for @item in @shopping_list
= @item
@PavloConan
PavloConan / Generating comment model in rails console
Last active February 9, 2016 10:59
generating comment model
$ rails generate model Comment body:text blog_post:references
class Comment < ActiveRecord::Base
belongs_to :blog_post
end
@PavloConan
PavloConan / #timestamp_create_comments.rb
Last active February 9, 2016 11:46
create comments table
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.text :body
t.references :blog_post
t.timestamps
end
end
end
@PavloConan
PavloConan / migration
Created February 9, 2016 11:49
rake migrate
$ rake db:migrate
class AddUserIdToComments < ActiveRecord::Migration
def change
add_column :comments, :user_id, :integer
add_index :comments, :user_id
end
end