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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:58:08+00:00 2026-05-18T04:58:08+00:00

Is it acceptable keep logic in view templates (in MVC terms and Rails specifically)?

  • 0

Is it acceptable keep logic in view templates (in MVC terms and Rails specifically)? Is there any way to avoid something like this?

<% if current_user %>
  Welcome, <%= current_user.name %>.
  <%= link_to "Sign Out", signout_path %>
<% else %>
  <%= link_to "Sign in with Twitter", "/auth/twitter" %>
<% end %>

Or am I inventing a “bicycle” and the upper stuff goes well?

  • 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-18T04:58:09+00:00Added an answer on May 18, 2026 at 4:58 am

    Comes down to preference of course. I would say that the above is pretty acceptable. Simple conditions and loops are pretty standard in a view. I would say the things to avoid would be assigning variables, hitting models for data you haven’t already gathered, etc.

    If you don’t want anything like tha in there, you can always build helpers. This kind of thing has to be somewhere.

    edit:

    a good rule of thumb is “does this code directly relate to the presentation?” I would say the answer regarding your above case is yes.

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

Sidebar

Related Questions

Is the following code acceptable. That is, is this the right way to do
Is this an okay practice or an acceptable way to use PHP's error suppressing?
Searching for a way to keep a registry of views and named adapters in
I like to keep my unit tests pretty simple and easy to follow. I
I'd like to keep a line of text together such that either the whole
To keep the global namespace clean, my JavaScript code is wrapped like this: (function()
I'll keep this short and simple. As part of PHP's mcrypt library there are
Is there a way to select designtime packages on a project bases? Packages are
I keep getting this 406 (Not Acceptable) error when i type in an autocomplete
I keep getting this HttpMediaTypeNotAcceptableException error for AJAX requests when using with Spring MVC

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.