[Rails] Re: team captain - habtm w/has_one...
Michael Barinek
barinek at gmail.com
Thu Jul 27 01:05:42 GMT 2006
what if they don't select their-self?
here is the view...
<% @selected = @team.users.collect { |v| v.id.to_i } %>
<select name="membership[user_ids][]" multiple="multiple">
<%= options_from_collection_for_select(@users, "id", "login",
@selected) %>
and the db...
create table memberships (
id int(10) unsigned not null auto_increment,
team_id int(10) unsigned not null,
user_id int(10) unsigned not null,
is_the_captain tinyint(1) not null default '0',
primary key (id),
unique (team_id, user_id),
foreign key (team_id) references teams(id),
foreign key (user_id) references users(id)
) engine=innodb default charset=latin1;
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list