Skip to content

Instantly share code, notes, and snippets.

@acconrad
Created January 19, 2011 04:37
Show Gist options
  • Save acconrad/785694 to your computer and use it in GitHub Desktop.
Save acconrad/785694 to your computer and use it in GitHub Desktop.
<%= form_for @user do |f| %>
<%= f.label "Widgets:" %>
<%= f.text_field "x" %>
<%= f.submit "Add widgets to User" %>
<% end %>
class User < ActiveRecord::Base
has_many :widgets
end
...
def edit
@user = User.find(1)
end
def update
# this method takes the value from the form
# splits it into an array (split by commas)
# and adds 1 widget per comma-separated word
end
...
class Widget < ActiveRecord::Base
belongs_to :user
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment