0

having trouble with the if else -- I am thinking it is a syntax issue but I can not seem to get it. I used the suggestions below and it is still throwing a 500 error. I do not know the exact error because there is a custom error message and "a 500" is the only technical information given. is there a debug mode that I can enable on the dev side that would provide additional information?

What I am trying to do is display a drop down and allow for a selection if you are a "DSD" otherwise the drop down should be disabled, which is why I need the IF statement.

Here is the current if statement that I am running:

Updated

        <% 
           if (sign_on.acctypw1.strip =="DS") 
               select_tag(:distributor_number_X,  options_for_select(distributors_array), {:style => "width:400px", :disabled => "true"}) 
           else (sign_on.acctypw1.strip =="DSD")               
               select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px" })
           end
        %>

here is the error from the server log:

[Mon Mar 25 09:33:41 2013] [notice] caught SIGTERM, shutting down
[ pid=8710 thr=77929640 file=utils.rb:176 time=2013-03-25 09:33:42.922 ]: *** Exception SignalException in PhusionPassenger::ClassicRails::ApplicationSpawner (SIGTERM) (process 8710, thread #<Thread:0x94a3950>):
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:343:in `select'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:343:in `server_main_loop'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:180:in `start'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/classic_rails/application_spawner.rb:149:in `start'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/spawn_manager.rb:219:in `block (2 levels) in spawn_rails_application'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/spawn_manager.rb:214:in `block in spawn_rails_application'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
from <internal:prelude>:10:in `synchronize'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/helper-scripts/passenger-spawn-server:99:in `<main>'
[Mon Mar 25 09:35:50 2013] [notice] Apache/2.2.14 (Ubuntu) Phusion_Passenger/3.0.1 configured -- resuming normal operations
 [Mon Mar 25 10:03:31 2013] [notice] caught SIGTERM, shutting down
 [Mon Mar 25 10:03:47 2013] [notice] Apache/2.2.14 (Ubuntu) Phusion_Passenger/3.0.1 configured -- resuming normal operations
3
  • you left out an o in your first options_for_select Commented Mar 22, 2013 at 16:02
  • What's the 500 error? Commented Mar 22, 2013 at 19:00
  • @bobkendall When you can post the error, it will help. :) Commented Mar 22, 2013 at 21:14

3 Answers 3

4

I assume this is in your view (erb.html file) Your if and else statements also have to go inside <% %>.

<% if sign_on.acctypw1.strip =="DS" %>
  <%= select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px", :disabled => "true"}) %>
<% else sign_on.acctypw1.strip =="DSD" %>             
  <%= select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px" })  %>
<% end %>

Also, something to keep in mind --

<% "This will be evaluated" %>
<%= "This will be evaluated and outputted to your view" %>
Sign up to request clarification or add additional context in comments.

1 Comment

from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:343:in select' from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:343:in server_main_loop'
0

You want to use elsif instead of else there.

You also need to wrap your if/elsif/end in <% %> tags as this is ERB

2 Comments

made the changes and now getting a 500
I changed the block of code to the following and I am still getting the logged error above <% if (sign_on.acctypw1.strip =="DS") %> <%=select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px", :disabled => "true"}) %> <% elsif (sign_on.acctypw1.strip =="REP") %> <%=select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px", :disabled => "false"}) %> <% end %>
-1
<%= 
   if (sign_on.acctypw1.strip =="DS") 
       select_tag(:distributor_number_X,  options_for_select(distributors_array), {:style => "width:400px", :disabled => "true"}) 
   else (sign_on.acctypw1.strip =="DSD")               
       select_tag(:distributor_number_X, options_for_select(distributors_array), {:style => "width:400px" })
   end
%>

4 Comments

this seems the most efficient but still fails a s a 500
no they have a custom error page catching the error and only displaying that it is a 500 is there and extended bug mode I can enable?
Can you ssh into the server and look at the log file? Not much we can do to help without the actual error message.
Why the down vote with no reason? This is a perfectly valid solution as far as i know.

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.