Let''s say I have a "main" controller/view and a "sub" controller/view. If I have defined a partial in "main" for the site header (_site_header.rhtml) can I share it with "sub" or does "sub" have to duplicate it, use a symbolic link to the file, or convert the cool partial into an ugly helper? It would be nice to have a shared placed for partials. Similar to app/helper/application.rb. I know I could use a helper, but when it comes to views, partials are so much nicer. Thanks, Dale -- Posted via http://www.ruby-forum.com/.
put the shared partial in app/views/shared/ and reference it with <%= render :partial => ''shared/partial_name'' %> hope this helps, Mike On 23/06/2006, at 10:57 PM, Dale Martenson wrote:> Let''s say I have a "main" controller/view and a "sub" controller/view. > If I have defined a partial in "main" for the site header > (_site_header.rhtml) can I share it with "sub" or does "sub" have to > duplicate it, use a symbolic link to the file, or convert the cool > partial into an ugly helper? > > It would be nice to have a shared placed for partials. Similar to > app/helper/application.rb. > > I know I could use a helper, but when it comes to views, partials > are so > much nicer. > > Thanks, > Dale > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
In your sub view, you can use this to render the partial from main. render :partial => ''main/site_header'' Also, you could put the header in a layout and have each controller use that layout. mark On 6/23/06, Dale Martenson <dale.martenson@gmail.com> wrote:> Let''s say I have a "main" controller/view and a "sub" controller/view. > If I have defined a partial in "main" for the site header > (_site_header.rhtml) can I share it with "sub" or does "sub" have to > duplicate it, use a symbolic link to the file, or convert the cool > partial into an ugly helper? > > It would be nice to have a shared placed for partials. Similar to > app/helper/application.rb. > > I know I could use a helper, but when it comes to views, partials are so > much nicer. > > Thanks, > Dale > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Mark Van Holstyn mvette13@gmail.com http://lotswholetime.com
I usually create a folder under views called "shared" and then put all my shared partials in there. I then reference them from any controller view with render :partial => ''shared/_partial'' -- "Impossible is nothing." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060624/9d7f1160/attachment.html