Skip to content

Instantly share code, notes, and snippets.

View ebrugulec's full-sized avatar
💃

Ebru Gulec ebrugulec

💃
  • Berlin, Germany
View GitHub Profile
class CreateProducts < ActiveRecord::Migration[5.1]
def change
create_table :products do |t|
t.string :title
t.timestamps
end
end
end
class CreateEmployees < ActiveRecord::Migration[5.1]
def change
create_table :employees do |t|
t.string :name
t.timestamps
end
end
end
class AddEmailIndexToUsers < ActiveRecord::Migration
def change
add_index :users, :email
end
end
create_table "users", force: :cascade do |t|
t.string "email"
t.string "password_digest"
t.string "username"
t.string "token"
end
<p><%= todo_item.content %></p>
<%= link_to "Delete", todo_list_todo_item_path(@todo_list, todo_item.id), method: :delete, data: { confirm: "Are you sure?" } %>
<%= link_to "Mark as Complete", complete_todo_list_todo_item_path(@todo_list, todo_item.id), method: :patch %>
Rails.application.routes.draw do
resources :todo_lists do
resources :todo_items do
member do
patch :complete
end
end
end
root 'todo_lists#index'
end
Rails.application.routes.draw do
resources :todo_lists do
resources :todo_items do
end
end
root 'todo_lists#index'
end
<p id="notice"><%= notice %></p>
<p>
<strong>Title:</strong>
<%= @todo_list.title %>
</p>
<p>
<strong>Description:</strong>
<%= @todo_list.description %>
</p>
<div id="todo_items_wrapper">
<p><%= todo_item.content %></p>
<%= link_to "Delete", todo_list_todo_item_path(@todo_list, todo_item.id), method: :delete, data: { confirm: "Are you sure?" } %>
<%= form_for([@todo_list, @todo_list.todo_items.build]) do |f| %>
<%= f.text_field :content, placeholder: "New Todo" %>
<%= f.submit %>
<% end %>