Skip to content

Instantly share code, notes, and snippets.

@tafryn
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tafryn/9532998 to your computer and use it in GitHub Desktop.
Save tafryn/9532998 to your computer and use it in GitHub Desktop.
-----------------models/*--------------------
class Alpha < ActiveRecord::Base
has_many :bravos, :dependent => :destroy
has_many :charlies, :through => :bravos
end
class Bravo < ActiveRecord::Base
belongs_to :alpha
has_and_belongs_to_many :charlies
end
class Charlie < ActiveRecord::Base
has_and_belongs_to_many :bravos
has_one :delta
end
class Delta < ActiveRecord::Base
belongs_to :charlie
end
---------------------------routes.rb---------------------------
resources :alphas do
resources :bravos
resources :charlies
end
resources :charlies do
resources :delta
end
-----------------views/alpha/show.html.erb---------------------
<%= render @alpha.charlies %>
-----------------views/charlie/_charlie.html.erb---------------
<%# charlie fields %>
<%= render :partial => "deltas/form", :locals => { :charlie => charlie } %>
-----------------views/charlie/_form.html.erb------------------
<%= form_for [charlie, charlie.build_delta], url: charlie_delta_path(charlie) do |f| %>
<%# form stuff %>
<% end %>
--------------------------ERRORS-------------------------------
No route matches {:action=>"show", :controller=>"delta", :alpha_id=>"1", :id=>nil, :charlie_id=>#<Audit id: 2, ...>, :format=>nil} missing required keys: [:id]
--------------------------rake routes--------------------------
Prefix Verb URI Pattern Controller#Action
home_index GET /home/index(.:format) home#index
alpha_bravos GET /alphas/:alpha_id/bravos(.:format) bravos#index
POST /alphas/:alpha_id/bravos(.:format) bravos#create
new_alpha_bravo GET /alphas/:alpha_id/bravos/new(.:format) bravos#new
edit_alpha_bravo GET /alphas/:alpha_id/bravos/:id/edit(.:format) bravos#edit
alpha_bravo GET /alphas/:alpha_id/bravos/:id(.:format) bravos#show
PATCH /alphas/:alpha_id/bravos/:id(.:format) bravos#update
PUT /alphas/:alpha_id/bravos/:id(.:format) bravos#update
DELETE /alphas/:alpha_id/bravos/:id(.:format) bravos#destroy
alpha_charlies GET /alphas/:alpha_id/charlies(.:format) charlies#index
POST /alphas/:alpha_id/charlies(.:format) charlies#create
new_alpha_charlie GET /alphas/:alpha_id/charlies/new(.:format) charlies#new
edit_alpha_charlie GET /alphas/:alpha_id/charlies/:id/edit(.:format) charlies#edit
alpha_charlie GET /alphas/:alpha_id/charlies/:id(.:format) charlies#show
PATCH /alphas/:alpha_id/charlies/:id(.:format) charlies#update
PUT /alphas/:alpha_id/charlies/:id(.:format) charlies#update
DELETE /alphas/:alpha_id/charlies/:id(.:format) charlies#destroy
alphas GET /alphas(.:format) alphas#index
POST /alphas(.:format) alphas#create
new_alpha GET /alphas/new(.:format) alphas#new
edit_alpha GET /alphas/:id/edit(.:format) alphas#edit
alpha GET /alphas/:id(.:format) alphas#show
PATCH /alphas/:id(.:format) alphas#update
PUT /alphas/:id(.:format) alphas#update
DELETE /alphas/:id(.:format) alphas#destroy
charlie_delta_index GET /charlies/:charlie_id/delta(.:format) delta#index
POST /charlies/:charlie_id/delta(.:format) delta#create
new_charlie_delta GET /charlies/:charlie_id/delta/new(.:format) delta#new
edit_charlie_delta GET /charlies/:charlie_id/delta/:id/edit(.:format) delta#edit
charlie_delta GET /charlies/:charlie_id/delta/:id(.:format) delta#show
PATCH /charlies/:charlie_id/delta/:id(.:format) delta#update
PUT /charlies/:charlie_id/delta/:id(.:format) delta#update
DELETE /charlies/:charlie_id/delta/:id(.:format) delta#destroy
charlies GET /charlies(.:format) charlies#index
POST /charlies(.:format) charlies#create
new_charlie GET /charlies/new(.:format) charlies#new
edit_charlie GET /charlies/:id/edit(.:format) charlies#edit
charlie GET /charlies/:id(.:format) charlies#show
PATCH /charlies/:id(.:format) charlies#update
PUT /charlies/:id(.:format) charlies#update
DELETE /charlies/:id(.:format) charlies#destroy
import POST /home/import(.:format) home#import
type GET /alphas/:alpha_id/type/:type_charlies(.:format) alphas#type
root GET / home#index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment