Change default view path for an ActionController

Hello all,

i would like to change the default view path for one of my controllers. Like StudentsController should use templates located in views/persons instead views/students. Is that possible?

Greetings, Mike

I’m pretty sure you can just call render at the end of the action to render whatever you want.

http://api.rubyonrails.org/classes/ActionController/Base.html#M000676

I’m not sure you would want to do this though.

jap thats right. but is there a way to change the default path without actually touching every controller method?

Would an after_filter work?

mike wrote:

Hello all,

i would like to change the default view path for one of my controllers. Like StudentsController should use templates located in views/persons instead views/students. Is that possible?

Greetings, Mike

Go to your routes file in config and do something similar:

map.persons '/persons', :controller => 'students', :action => 'index'

i would like to change the view path via a param

Hi,

I’d say something like that might do : (in your student controller, in the action you want)

respond_to do |format| format.html { render :controller => “person”, :action => your_action } end

Cyril

I just had the same problem and I solved it by creating symlinks between the folders. So, for your example, you could try this command in your view folder :

link -s persons students

It would be nice to have a more standard way to change the view folder path... Hope it helps!