How to define default template path in controller

StudentsController extendeds my basic RESTful UsersController. Student
is a named_scope in my User model.

I’d like the students controller to render templates in app/views/
users/, not app/views/students/. How can I do this DRYly without
redefining all the methods in UsersController?

entire students_controller.rb

class StudentsController < UsersController
protected
def find_users
@users = User.student.find(:all)
end
def find_user
@user = User.student.find(params[:id])
end
end

relevant parts of users_controller.rb

class UsersController < ApplicationController
before_filter :find_users, :only => [:index]
def index
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
#… other REST methods
protected
def find_users
@users = User.find(:all)
end
def find_user
@user = User.find(params[:id])
end
end

When I GET /students…
Template is missing
Missing template students/index.html.erb in view path /Path/To/MyApp/
app/views

In StudentsController I tried: append_view_path("/Path/To/MyApp/app/
views/users")…
Template is missing
Missing template students/index.html.erb in view path /Path/To/MyApp/
app/views:/Path/To/MyApp/app/views/users

Any ideas? Is there a better approach entirely? Perhaps some magic
routing?

Thanks!

Hi,

Anyone have used the “html to pdf convertors” on ruby.

Thanks in Advance,
Usha

Sorry wrong message, Please forgive for the inconvenience.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs