I think you want to use the :key as the identifier for the selection.
= f.collection_select(:web_server, WebServer.all, :key, :name)
--
Brian
On Sep 1, 2010, at 2:48 PM, John Axel Eriksson wrote:
> I'm not exactly an expert on Rails but I've built a few simpler apps. Now
> I'm working on an app using Ripple and I'm having a few issues, perhaps
> I just haven't grasped riak/ripple yet...
>
>
> Anyway...
>
>
> class Client
> include Ripple::Document
>
> timestamps!
>
> property :name, String
> property :hostname, String
> property :url, String
> property :blocked, Boolean
>
> key_on :hostname
>
> one :web_server
>
> def id
> hostname
> end
>
>
> end
>
>
> class WebServer
> include Ripple::Document
>
> timestamps!
>
> property :name, String
> many :users
> many :clients
>
> key_on :name
>
> def id
> name
> end
>
> end
>
> in Rails console:
>
> c = Client.new(:name => 'abc')
> ws = WebServer.find('some.domain.name')
>
> c.web_server = ws
>
> c.save
>
> the above works just fine (and doing curl -i against the resources in riak
> shows the links too) but...
>
> in a (haml) form I do:
>
> .select
> %label= f.label :web_server
> = f.collection_select(:web_server, WebServer.all, :id, :name)
>
> but here I get an error when saving saying:
> ArgumentError (Invalid value "some.domain.name" for association web_server
> of type WebServer on <Client:abc name="abc" created_at=Wed Sep 01 17:38:08
> UTC 2010 updated_at=Wed Sep 01 17:38:13 UTC 2010 url="abc.somedomain.name"
> blocked=nil hostname="abc">):
> app/controllers/clients_controller.rb:63:in `update'
>
>
> I ported the code over from a MongoDB-version of the app where these forms
> worked just fine. I'm having trouble seeing whats wrong with this, maybe I
> don't know rails
> well enough...
>
> Also, does ripple support accepts_nested_attributes_for (afaict it doesn't)?
> _______________________________________________
> riak-users mailing list
> [email protected]
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com