views:

21

answers:

1

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.erb
  _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.

A: 

Just create helper for that:

def render_choice(name)
  render :partial => "myview/choices/#{nane}"
end
gertas