partials are named with a leading underscore to distinguish them from regular views, even though they are referred to without the underscore
http://guides.rubyonrails.org/layouts_and_rendering.html#using-partialsSo I had some code that said:
render :partial => "short_list", :collection => @items
which was in an ajax call. I was doing it with 'render :inline' but partials seemed like a much better idea. Well, that wasn't such a great idea. I kept getting ActionView::MissingTemplate errors. Tried about 15 things, read three or four blog posts, several SO questions. Then I noticed one that had an underscore in front of the file name. Odd. So I go read the docs and sure enough.
Even if you specifically say:
render :partial => "item/short_list", :collection => @items
it will not find your partial because it doesn't start with an underscore. Even though there is only one view in that directory.
That, that is stupid. Conventions are fine when you want to just sorta let the app wire things up. But when you specifically say "do it this way" the convention should not get in your way.
The odd thing about Ruby is that it is much more of an RTFM language than C# -- because there's no compiler to tell you "hey, you did that wrong" and the autocomplete is usually just not there.
That, that is stupid. Conventions are fine when you want to just sorta let the app wire things up. But when you specifically say "do it this way" the convention should not get in your way.
The odd thing about Ruby is that it is much more of an RTFM language than C# -- because there's no compiler to tell you "hey, you did that wrong" and the autocomplete is usually just not there.
No comments:
Post a Comment