Created
December 1, 2008 04:46
-
-
Save piclez/30626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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