I have a link that I want users to press and it will go to a custom view (new.worker.html.erb) inside the absences object how do I do this?
I currently have a link_to a method inside my controller called render which checks the user’s session for staff_type to decide where the user should be redirected to
edit: as pointed out by the commenters the answer is to call the relevant controller to your view in your link_to, then perform the check for the right render inside the controller like so:
if session[:user].staff_type == 3
render "new_worker"
which points to the new_worker view inside the relevant view
Ok, so, different staff members are different staff types, right? and worker is one of them?
What I would probably do is in your staffs controller, in show — which is where I assume you want to render a different template, when you’re looking at a particular person who has a particular staff_type — is to find the Staff Member, and then look at their :staff_type attribute, and do an if or a case to render the corresponding partial.
The above renders for the show action (passes those variables) but with a custom layout called worker.
Or, instead of a render as above, I’d recommend using the same skeleton and then rendering a different partial for each different staff type, using this render:
In that case, the view would be called probably
_worker.rhtmlSee info here: http://rails.rubyonrails.org/classes/ActionController/Base.html#M000464
You can use the above in any controller action, really. But you need to do this in a controller, or else re-organize your resources.