 |
Forums |
Admin Start New Thread
By: Luke Galea
RE: shared partial for sub_list? [ reply ] 2006-12-06 20:41
|
Hi,
It should be relatively easy to change the code to handle this.
I think a good way would be to modify the helper function sub_list_content to accept a third parameter with the name of the partial.
Here's a quick untested bit to replace the method in sub_list_helper.rb:
def sub_list_content( model = 'Note', parent = 'incomplete', partial = nil )
model = model.to_s.tableize.singularize
models = model.pluralize
#If partial is nil, set to model for normal behavior
partial ||= model
content = render :partial => partial, :collection => eval("@#{parent}.#{models}")
"<div id=\"#{models}\"> #{content} </div>"
end
|
By: yossarian dunbar
shared partial for sub_list? [ reply ] 2006-12-06 15:52
|
Hi, I've got a class call UrlAttachment that I've defined using
belongs_to :attachable, :polymorphic => true
So, I can attach URLs to any class (e.g. article, company, project, etc.) that implements
has_many :url_attachments, :as => :attachable
Most of the time, I'd like to do this using sub_list.
Is it possible to define a _url_attachment sub_list partial that can be shared?
The docs currently say that the _url_attachment.rhtml partial should be in the same view directory as the form that it's included in - it'd be nice to be able to specify a partial like "/shared/_url_attachment" somewhere.
Is this do-able?
|
|
 |