I have a set of partials that are used to update a section of a form depending on the user's choice from a drop-down menu. There are a lot of different choices, so rather than having a view folder like this:
app/views/myview/
_choice001.html.er开发者_C百科b
_choice002.html.erb
...
_choice998.html.erb
_choice999.html.erb
_form.html.erb
_sharedchoicestuff1.html.erb
_sharedchoicestuff2.html.erb
edit.html.erb
new.html.erb
I want to lay it out like this:
app/views/myview/
choices/
_choice001.html.erb
_choice002.html.erb
...
_choice998.html.erb
_choice999.html.erb
_sharedchoicestuff1.html.erb
_sharedchoicestuff2.html.erb
_form.html.erb
edit.html.erb
new.html.erb
If I do that, then I know I need to change render :partial => whatever
to render :partial => "myview/choices/#{whatever}"
which is OK in the form, but I don't want to have to change it in all the choice templates. Is there a way to add '.' to the view path so I can still have render :partial => 'sharedchoicestuff1'
in the choice templates.
Just create a helper for that:
def render_choice(name)
render "myview/choices/#{name}"
end
精彩评论