Skip to content

Instantly share code, notes, and snippets.

@HeroicEric
Created September 26, 2011 01:10
Show Gist options
  • Save HeroicEric/1241406 to your computer and use it in GitHub Desktop.
Save HeroicEric/1241406 to your computer and use it in GitHub Desktop.
# domains/show.html.haml
%h2 Keywords
= link_to "New keyword", new_domain_keyword_path(:domain_id => @domain.id)
# keywords/new.html.haml
= form_for([@domain, @keyword]) do |f|
= f.label :term
= f.text :term
# controllers/keywords_controller.rb
class KeywordsController < ApplicationController
def new
@domain = Domain.find(params[:domain_id])
@keyword = @domain.keywords.new
end
end
# Scheme
create_table "domains", :force => true do |t|
t.string "name"
t.string "url"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "domains_keywords", :force => true do |t|
t.integer "domain_id"
t.integer "ticket_id"
end
create_table "keywords", :force => true do |t|
t.integer "rank"
t.string "term"
t.integer "domain_id"
t.datetime "created_at"
t.datetime "updated_at"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment