Skip to content

Instantly share code, notes, and snippets.

@piclez
Created December 1, 2008 04:46
Show Gist options
  • Save piclez/30626 to your computer and use it in GitHub Desktop.
Save piclez/30626 to your computer and use it in GitHub Desktop.
class Segment
include DataMapper::Resource
property :id, Serial
property :title, String
has n, :products, :through => Resource
end
class Product
include DataMapper::Resource
property :id, Integer, :serial => true
property :title, String
property :permalink, String
has n, :segments, :through => Resource
end
Product form view:
<%= select :segments, :collection => @segments, :value_method => "id", :text_method => "title", :label => 'Segmento' %>
<%= text_field :title, :label => "Title" %>
Products controller
def create(product)
@product = Product.new(product)
@product.save
end
Ideally I'd like to have a select tag with segments[]
Error:
undefined method `collection=' for "1":String
gems/gems/dm-core-0.9.6/lib/dm-core/collection.rb in `relate_resource' 537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment