Solution??
Wow. So I instantiate @tag (a new tag object) for simple_form to use. The problem is that this new tag has no id yet. And this new tag gets added to @tag_list. So when I iterate over @tag_list to create the 'edit' links, eventually it hits a tag with no id and throws the error. Least I think this is what's happening.
pry output:
~/Desktop/coding_resources/programs/md_notes
14:31:50 davemox@Daves-MacBook-Pro $ bundle exec rspec --tag feature
Run options: include {:feature=>true}
From: /Users/davemox/Desktop/coding_resources/programs/md_notes/app/views/tags/index.html.haml @ line 5 ActionView::CompiledTemplates#_app_views_tags_index_html_haml__3176058435137530461_70362022596640:
1: .large-3.medium-3.columns.hide-for-small#no-padding-right
2: = render "partials/side_navbar"
3: .small-12.medium-9.large-9.columns
4: - @tag_list.each do |tag|
=> 5: = binding.pry
6: = link_to "#{tag.name}", edit_collection_tag_path(@collection, tag), class: 'button tiny'
7: = simple_form_for @tag do |f|
8: = f.input :name, label: false
9: = f.button :submit, "Add Tag"
[1] pry(#<#<Class:0x007ffcdeb90798>>)> tag
=> #<Tag id: 2, name: "Haml", created_at: "2014-02-05 19:32:02", updated_at: "2014-02-05 19:32:02", collection_id: 1>
[2] pry(#<#<Class:0x007ffcdeb90798>>)> @tag_list
=> [#<Tag id: 2, name: "Haml", created_at: "2014-02-05 19:32:02", updated_at: "2014-02-05 19:32:02", collection_id: 1>,
#<Tag id: 1, name: "SimpleForm", created_at: "2014-02-05 19:32:02", updated_at: "2014-02-05 19:32:02", collection_id: 1>,
#<Tag id: nil, name: nil, created_at: nil, updated_at: nil, collection_id: 1>]
[3] pry(#<#<Class:0x007ffcdeb90798>>)> @collection
=> #<Collection id: 1, name: "Productivity", description: nil, user_id: 1, created_at: "2014-02-05 19:32:02", updated_at: "2014-02-05 19:32:02">
[4] pry(#<#<Class:0x007ffcdeb90798>>)>
@collection
before_action :set_collection
...
...
def set_collection
@collection = @user.collections.find(params[:collection_id]) if params[:collection_id]
end
view file
- @tag_list.each do |tag|
= link_to "#{tag.name}", edit_collection_tag_path(@collection, tag)
controller
def index
@tag_list = @collection.tags
@tag = @collection.tags.new
end
error
No route matches {:collection_id=>#<Collection id: 2, name: "Marketing/Sales", description: "I love marketing!!!!", user_id: 2, created_at: "2014-02-02 02:43:19", updated_at: "2014-02-02 04:36:43">, :id=>#<Tag id: nil, name: nil, created_at: nil, updated_at: nil, collection_id: 2>} missing required keys: [:id]