0

I have a strange error that came about when I changed my app from mongrel to mod_rails.

My app changes from a two column layout to a three column layout depending on where the user is in the app. My application layout relies on several helpers to put the divs in the right place.

In application_helper.rb:

  def left_column_layouts
   if  params[:controller] == "users" && params[:action] == "show" ||
       params[:controller] == "friendships" && params[:action] == "index" ||
       params[:controller] == "tags" && params[:action] == "index"
       true
   else
       false
   end 
end

I also have similar logic for where the three column layouts.

Then, in my layout file:

    <% if left_column_layouts %>
    <div class="colmask leftmenu">
    <div class="colleft">
  <%= yield %>
    </div>
    </div>
<% elsif three_columns_with_blank_sides %>
<div class="colmask threecol">
<div class="colmid">
<div class="colleft">
    <%= yield %>
<div class="col2">
</div>
<div class="col3">
</div>
</div>
</div>
</div>
<% else #Three column layout %>
    <div class="colmask threecol">
    <div class="colmid">
    <div class="colleft">
<%= yield %>
    </div>
    </div>
    </div>
<% end %>

This worked well until I changed to mod rails. I can't imagine why mod rails would make this part of the app simply not work.

Interesting note: I went to the https parts of my site and the layout was loading without a problem. My server support guys said I should clear the cache but the problem persists.

Any help would be appreciated!

17
  • Can't be a problem with mod_rails. What else did you do? Commented Apr 12, 2010 at 19:38
  • Let's see... I did modify the layout file a bit to put in a new header picture, but I can't imagine this has anything to do with the helper not loading. The fact that it's loading on the secure pages and not the regular ones really puzzles me. Commented Apr 12, 2010 at 19:45
  • When you say it "doesn't work", what do you mean? Nothing rendered? Error generated? View the source of the rendered page and post it here. Commented Apr 12, 2010 at 20:03
  • 1
    which version of ruby do you use with mod rails? REE? Commented Apr 12, 2010 at 20:23
  • 1
    @Kenji Crosland, they most likely referred to clearing the cache on the server-side. You may want to ask them what steps to take to clear the cache. The fact that it works with SSL is disturbing. Commented Apr 13, 2010 at 7:14

1 Answer 1

1

I know that this is an old post, but just to make sure that others would see it. If I correctly understand what you want, I believe the problem lies in the logic used in your condition.

If you want to display left column when controller:action is users:show or friendships:index or tags:index, your logic condition is incorrect. You need parentheses to correct them.

For example, let's say users is 'A', show is 'B', friendships is 'C', index of friendships is 'D', tags is 'E', and index of tags is 'F'.

Your code represents A && B || C && D || E && F, but I believe what you want is (A && B) || (C && D) || (E && F). Because A && B || C && D || E && F is not equal to (A && B) || (C && D) || (E && F), the method may return incorrect result. To be more clear, let say all params from A to E are true but F is false. Your method will return false which is supposed to be true. That may be the case.

Sign up to request clarification or add additional context in comments.

1 Comment

Hey Taywin. Thanks for the help! The server did a major upgrade and now the problem is gone. Wierd. I should implement these changes though to make sure it doesn't happen again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.