Hey guys, i''m new to rails and need some help. I want to create a simple dropdown which gets its values from a model. I found a propably suitable function but I dont quite get how to use it. Here is what i did - and what does not work - but maybe you''ll get an idea for what it is meant for: Server: <%= options_from_collection_for_select(@server, "pid", "title", @account.server) %> ... Well ''account'' has a column which saves the server_id that correspons to the id from servers table. I hope you know what i mean... my english is a bit rusty ;) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On 17.7.2007, at 14.25, Ooze wrote:> > Hey guys, > > i''m new to rails and need some help. I want to create a simple > dropdown which gets its values from a model. > > I found a propably suitable function but I dont quite get how to use > it. Here is what i did - and what does not work - but maybe you''ll get > an idea for what it is meant for: > > Server: <%= options_from_collection_for_select(@server, "pid", > "title", @account.server) %> > > ... > Well ''account'' has a column which saves the server_id that correspons > to the id from servers table.<%= select(:account, :server_id, Server.find(:all).collect{ |s| [s.name, s.id] }) %> (http://api.rubyonrails.org/classes/ActionView/Helpers/ FormOptionsHelper.html#M000506) This list is for discussing the development of the Rails framework, though. Please use the general Rails mailing list (http:// groups.google.com/group/rubyonrails-talk) for help requests. //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi
YAY! It works ... thanks a lot! On 17 Jul., 14:05, Jarkko Laine <jar...@jlaine.net> wrote:> On 17.7.2007, at 14.25, Ooze wrote: > > > > > > > Hey guys, > > > i''m new to rails and need some help. I want to create a simple > > dropdown which gets its values from a model. > > > I found a propably suitable function but I dont quite get how to use > > it. Here is what i did - and what does not work - but maybe you''ll get > > an idea for what it is meant for: > > > Server: <%= options_from_collection_for_select(@server, "pid", > > "title", @account.server) %> > > > ... > > Well ''account'' has a column which saves the server_id that correspons > > to the id from servers table. > > <%= select(:account, :server_id, Server.find(:all).collect{ |s| > [s.name, s.id] }) %> > > (http://api.rubyonrails.org/classes/ActionView/Helpers/ > FormOptionsHelper.html#M000506) > > This list is for discussing the development of the Rails framework, > though. Please use the general Rails mailing list (http:// > groups.google.com/group/rubyonrails-talk) for help requests. > > //jarkko > > -- > Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce.comhttp://odesign.fi > > smime.p7s > 3KHerunterladen--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---