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 8001345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:04:16+00:00 2026-06-04T16:04:16+00:00

I am writing a Ruby on Rails application with a controller called pages_controller that

  • 0

I am writing a Ruby on Rails application with a controller called “pages_controller” that is responsible for displaying pages to users. There are 3 different types of pages that can be displayed, and different things have to happen on the back end in each case, so I decided to break the functionality out into 3 methods within the controller. When the user requests a page, the “show” method is called, which figures out whether the page:
1. Belongs to the user
2. Belongs to another user, and can be viewed by the user requesting it
3. Belongs to another user, and cannot be viewed by the user requesting it (unauthorized)

The appropriate method is then called from there to display the page. The code looks something like this:

def show
    if (something)
      showMine

    elsif (something else)
      showAnother
    else
      showUnauthorized
    end
end

def showUnauthorized

    respond_to do |format|
      format.html # showUnauthorized.html.erb
    end
end

def showMine

    respond_to do |format|
      format.html # showMine.html.erb
    end
end

def showAnother

    respond_to do |format|
      format.html # showAnother.html.erb
    end
end

I am getting a template missing error because rails wants to render a view when “show” is called, but I do not want any views to be rendered when “show” is called. I simply want “show” to call the correct method from there, and the corresponding view for that method (showMine, showAnother, or showUnauthorized) to be rendered. How can I do this? Or am I going about this the wrong way entirely?

  • 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-06-04T16:04:17+00:00Added an answer on June 4, 2026 at 4:04 pm

    You need to declare these new actions that you have created in the routes file, as they don’t belong to the RESTful routes.
    I sugest to keep only the show action in your controller and create the IFs in the show view using the render method to include the partials(_showMine.html.erb, showAnother.html.erb, showUnauthorized)

    example:

    show view:

    if (something)
      <%= render 'showMine' %>
    elsif (something else)
      <%= render 'showAnother' %>
    else
      <%= render 'showUnauthorized' %>
    end
    

    I hope it helps…

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

Sidebar

Related Questions

I am writing ruby on rails application, which will have 2 different users types
I am writing a ruby on rails 3 application that is very simple: users
I am writing a Ruby on Rails(3) application that relies on an xml feed
I'm currently writing an application in ruby on rails that uses AWS. I see
I am writing a ruby on rails application that has large file uploads. (20-100MB).
I'm writing a non-Rails ruby application (gasp!) and would like to be able to
Background: I'm writing a 'standard' (nothing special) web application in Ruby (not Rails) and
Im writing a ruby application that can post comments on behalf of the user
Does Webrat require that the web application be written in Ruby/Rails? I'd like to
I am writing a web based application using Ruby on Rails. In one of

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.