没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
oss.trustie.net/open_source_projects | 主页 > 开源项目社区 > multimodel-forms |
multimodel-forms
|
0 | 0 | 18 |
贡献者 | 讨论 | 代码提交 |
Install git clone git://github.com:sudothinker/multimodel-forms.gitAboutThis plugin allows multiple models to have a place in one form. For example, if an article model has_many links. The links can be edited, created, deleted and even sorted (acts_as_list) from the article edit/new form. Included ajax helpers so links can be added and deleted client side and db is only touched when form is submitted.
This is largely derived from Ryan Bates' tutorial over at: http://railscasts.com/episodes/75
article.rb
class Article < ActiveRecord::Base
has_many_with_attributes :links
end
--
link.rb
class Link < ActiveRecord::Base
belongs_to :article
end
Can now add a view partial to render the article form and edit the associated links.
articles/_form.rhtml
Title
Links
'links/link', :collection => @article.links %>
links/_link.rhtml
nil %>
SVN logAdded datetime field to links to show that you have to use :index => '' instead of :index => nil for date_select helper tag Added validation to links and overrode field_error_proc to show associated validations working from within article model Applied patch to allow for CamelCase model names Added support for acts_as_list in through associations. See the sample project for usage. If the through relation has a position column then these will automatically be updated when the form is submitted. The view can also be sorted with drag and drop (implemented in the sample project