У меня есть переменная, которая как-то становится нулевой! Обратите внимание на отладчик в контроллере.
РЕДАКТИРОВАТЬ: похоже, что объект cvit не совпадает в контроллере и представлении. Как мне решить эту проблему?
в представлении:
<%= content_tag(:img,
content_tag(:map, @cvit.overlay_coords_gray.html_safe, :name => "#CViT_image_gray"),
{:src => "/data/04_cvit/#{@cvit.cvt_file}_gray.png", :usemap =>"#CViT_image_gray", :style => "display:block;margin-left:auto;margin-right:auto"} )
%>
Я получаю эту ошибку:
undefined method `html_safe' for nil:NilClass
, что относится к @ cvit.overlay_coords_gray
Вот базовая модель и контроллер:
Модель:
class Cvit < ActiveRecord::Base
attr_accessible :species,:program,:textup,:e_value,:filter,:min_identity,:cluster_dist,:fileup_file_name
attr_accessor :base_path, :fa_file, :text_file, :dbase, :source, :bl_file, :bl_sorted, :gff_file, :cvt_file, :db, :overlay_coords_gray
def initilize(*args)
super(*args)
end
def cvitSetup()
self.base_path = "blast_cvit/"
self.fa_file = "input.fa"
.
.
end
end
Контроллер:
def show
@cvit = Cvit.find(params[:id])
@cvit.cvitSetup()
@cvit.blast()
@cvit.generateGff()
@cvit.generateCvitImage()
logger.debug "overlay coords: #{@cvit.overlay_coords_gray.inspect}"
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @cvit }
end
end
Информация журнала (обратите внимание на использование отладчика, показывая, что он не равен нулю !!!!)
Creating scope :page. Overwriting existing method Cvit.page.
SQL (0.5ms) SHOW TABLES
Cvit Load (0.3ms) SELECT `cvits`.* FROM `cvits` WHERE `cvits`.`id` = 5 LIMIT 1
Started GET "/cvits/5" for 129.186.136.212 at Fri Aug 05 11:19:50 -0500 2011
Processing by CvitsController#show as HTML
Parameters: {"id"=>"5"}
Creating scope :page. Overwriting existing method Cvit.page.
!!!DEBUGGER!!! overlay coords: "<area onmouseover=\"mouseover_toggle('Glyma02g37330..173..179..694..700')\" shape=\"rect\" coords=\"173,694,179,700\" href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=42605601;stop=42707190;ref=Gm02;h_feat=Glyma02g37330@yellow\" target=\"_blank\"></area>\n<div id=\"Glyma02g37330..173..179..694..700\" style=\"border: 2px solid rgb(0, 0, 0);background-color: rgb(239,237,233); z-index: 1; visibility: hidden; position: absolute; width: 250px; left: 394px; top: 774px;\"><input type=\"button\" name=\"closeDiv\" value=\"Close\" onclick=\"mouseover_toggle('Glyma02g37330..173..179..694..700')\"></input><br /> Query = Glyma02g37330 <br />Target = Glyma02g37330 <br />Chromosome = Gm02 <br />Start = 42605601 <br />End = 42707190 <br /><a href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=42605601;stop=42707190;ref=Gm02;h_feat=Glyma02g37330@yellow\">Click to view in GBrowse</a></div>\n<area onmouseover=\"mouseover_toggle('Glyma02g37330..1013..1019..723..729')\" shape=\"rect\" coords=\"1013,723,1019,729\" href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=44520215;stop=44621936;ref=Gm14;h_feat=Glyma14g35580@yellow\" target=\"_blank\"></area>\n<div id=\"Glyma02g37330..1013..1019..723..729\" style=\"border: 2px solid rgb(0, 0, 0);background-color: rgb(239,237,233); z-index: 1; visibility: hidden; position: absolute; width: 250px; left: 394px; top: 774px;\"><input type=\"button\" name=\"closeDiv\" value=\"Close\" onclick=\"mouseover_toggle('Glyma02g37330..1013..1019..723..729')\"></input><br /> Query = Glyma02g37330 <br />Target = Glyma14g35580 <br />Chromosome = Gm14 <br />Start = 44520215 <br />End = 44621936 <br /><a href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=44520215;stop=44621936;ref=Gm14;h_feat=Glyma14g35580@yellow\">Click to view in GBrowse</a></div>\n<area onmouseover=\"mouseover_toggle('Glyma02g37330..313..319..147..153')\" shape=\"rect\" coords=\"313,147,319,153\" href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=6118288;stop=6218620;ref=Gm04;h_feat=Glyma04g07910@yellow\" target=\"_blank\"></area>\n<div id=\"Glyma02g37330..313..319..147..153\" style=\"border: 2px solid rgb(0, 0, 0);background-color: rgb(239,237,233); z-index: 1; visibility: hidden; position: absolute; width: 250px; left: 394px; top: 774px;\"><input type=\"button\" name=\"closeDiv\" value=\"Close\" onclick=\"mouseover_toggle('Glyma02g37330..313..319..147..153')\"></input><br /> Query = Glyma02g37330 <br />Target = Glyma04g07910 <br />Chromosome = Gm04 <br />Start = 6118288 <br />End = 6218620 <br /><a href=\"http://soybase.org/gb2/gbrowse/gmax1.01/?start=6118288;stop=6218620;ref=Gm04;h_feat=Glyma04g07910@yellow\">Click to view in GBrowse</a></div>\n"
CACHE (0.0ms) SELECT `cvits`.* FROM `cvits` WHERE `cvits`.`id` = 5 LIMIT 1
Rendered cvits/show.html.erb within layouts/glycine_max (3.3ms)
Completed 500 Internal Server Error in 4942ms
ActionView::Template::Error (undefined method `html_safe' for nil:NilClass):
88: <a href="/data/02_blastout/<%= @cvit.bl_file %>"><%= bl_state %></a>,
89: <a href="/data/03_gff/<%= @cvit.gff_file %>">CViT gff file</a>
90: <%= content_tag(:img,
91: content_tag(:map, @cvit.overlay_coords_gray.html_safe, :name => "#CViT_image_gray"),
92: {:src => "/data/04_cvit/#{@cvit.cvt_file}_gray.png", :usemap =>"#CViT_image_gray", :style => "display:block;margin-left:auto;margin-right:auto"} )
93:
94: %>
app/views/cvits/show.html.erb:91:in `_app_views_cvits_show_html_erb___1813186540_17224422620_0'
app/controllers/cvits_controller.rb:38:in `show'
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (8.8ms)
Rendered /usr/local/lib/ruby/gems/1.8/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (16.5ms)