2013-03-22 55 views
0

有問題,如果其他 - 我想這是一個語法問題,但我似乎無法得到它。我使用了下面的建議,它仍然拋出500錯誤。我不知道確切的錯誤,因爲存在自定義錯誤消息,「500」是唯一給出的技術信息。有沒有一個調試模式,我可以在開發端提供額外的信息?RUby在軌道上,如果其他語法混淆

我想要做的是顯示一個下拉菜單,並允許選擇,如果你是一個「DSD」,否則下拉應該被禁用,這就是爲什麼我需要IF語句。

這是當前的聲明,如果我運行:

更新

 <% 
      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 
     %> 

這裏是從服務器日誌中的錯誤:你想用elsif

[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 
+0

你離開了一個O您的第一個'options_for_select' – Huy 2013-03-22 16:02:00

+0

什麼是500錯誤? – 2013-03-22 19:00:33

+0

@bobkendall當你可以發佈錯誤時,它會有所幫助。 :) – 2013-03-22 21:14:47

回答

0

而不是在那裏。

您還需要來包裝你if/elsif/end<% %>標籤,因爲這是ERB

+0

進行了更改,現在得到一個500 – 2013-03-22 18:41:48

+0

我改變了代碼塊以下,我仍然得到上面<%如果(sign_on.acctypw1.strip ==「DS」)%> \t \t \t \t <%= select_tag(:distributor_number_X,options_for_select(distributors_array),{:式=> 「寬度:400像素」,是:停用=> 「真」})%> \t \t \t \t <%ELSIF(sign_on.acctypw1。條== 「REP」)%> \t \t \t \t <%= select_tag(:distributor_number_X,options_for_select(distributors_array),{:式=> 「寬度:400像素」,是:停用=> 「假」})%> \t \t \t \t <% end %> – 2013-03-29 15:01:18

4

我想這是你的看法(erb.html文件)你是否和else語句也有裏面去<% %>

<% 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 %> 

此外,東西要記住 -

<% "This will be evaluated" %> 
<%= "This will be evaluated and outputted to your view" %> 
+0

從/usr/local/ruby/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/lib/phusion_passenger/abstract_server.rb:343:in'選擇」從 \t /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' – 2013-03-25 14:05:28

-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 
%> 
+0

這似乎是最高效的,但仍然失敗asa 500 – 2013-03-22 20:15:37

+0

你能告訴我們錯誤是什麼嗎? – Catfish 2013-03-22 22:50:19

+0

不,他們有一個自定義錯誤頁面捕捉錯誤,只顯示它是一個500是否存在並擴展錯誤模式,我可以啓用? – 2013-03-25 12:01:14