Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:08:17+00:00 2026-05-27T00:08:17+00:00

I have a link that I want users to press and it will go

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:08:18+00:00Added an answer on May 27, 2026 at 12:08 am

    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.

    def show
      @staff = Staff.find(params[:id])
    
      case @staff.staff_type
      when "worker"
        render :action => "show", :layout => "worker" 
      else
         #other options
      end
    end
    

    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:

    render :partial => "worker", :object => @staff
    

    In that case, the view would be called probably _worker.rhtml

    See 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a link that will allow users to click it and it fetches
I have a link that goes like this: $this->Html->link('Welcome', array('controller' => 'users', 'action' =>
Suppose, I want to have a link or a button that when user click
I have a link that I want to look like a button so I
I have several sites that I want to link back to the main site
i have one domain link text i want to know that does google crawl
I have a UIWebView that loads a link, http://www.google.com/a/datacommsales.net . But I want to
I have next link that lets users navigate through a list of URL (stored
I have a table of users that I want other users to be able
Scenario: I have users that want to be able to change their username (unfortunately

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.