未初始化的常量ApplicationHelper告诉我什么?

不安全的信息技术

我遇到了一个uninitialized constant ApplicationHelper错误,但是我不确定这是在告诉我什么。

错误;

uninitialized constant ApplicationHelper::IpsTcpHdr
Extracted source (around line #120):

117:                                             'icmp'
118:                                         end %></td>
119:         <td class='src_ip'><%= get_attacker_ip(event.sid, event.cid).to_s(16).rjust(8,'0').scan(/.{2}/).map(&:hex).join('.') %></td>
120:         <td class='src_port'><%= get_tcp_sport(event.sid, event.cid) %></td>
121:         <td class='tgt_ip'><%= get_target_ip(event.sid, event.cid).to_s(16).rjust(8,'0').scan(/.{2}/).map(&:hex).join('.') %></td>
122:         <td class='tgt_port'><%= 'tgt_port' %></td>
123:       </tr>

这是ApplicationHelper;

  def get_tcp_sport(sid,cid)
    IpsTcpHdr.where('sid =? and cid =?', sid, cid).first.tcp_sport
  end

这是我的IpsTcpHdr;

class IpsTcpHdr < ActiveRecord::Base
  attr_accessible :sid, :cid, :tcp_sport, :tcp_dport, :tcp_seq, :tcp_ack, :tcp_off, :tcp_res, :tcp_flags, :tcp_win,
                  :tcp_csum, :tcp_urp
  self.primary_keys = :sid, :cid
  self.table_name = 'tcphdr'
  belongs_to :ips_ip_hdr
end

我认为这就是我所说的。

<td class='src_port'><%= get_tcp_sport(event.sid, event.cid) %></td>

这是数据库中的信息;

csdashboard=# SELECT * from tcphdr;
 sid | cid  | tcp_sport | tcp_dport |  tcp_seq   |  tcp_ack   | tcp_off | tcp_res | tcp_flags | tcp_win | tcp_csum | tcp_urp 
-----+------+-----------+-----------+------------+------------+---------+---------+-----------+---------+----------+---------
   1 |    1 |     61667 |        80 |  239316451 | 3044404141 |       8 |       0 |        24 |    8208 |    63248 |       0
   1 |    2 |     61670 |        80 | 3279522000 | 4110870482 |       8 |       0 |        24 |    8208 |    34845 |       0
蒂姆·迪金斯

这说明红宝石找不到常量(类)IpsTcpHdr,它是在ApplicationHelper中查找的。

您可以通过(需要”)IpsTcpHdr所在的文件来解决此问题。但是,您也可以使用Rails为您自动加载某些文件夹中的文件,但是您的文件必须名为ips_tcp_hdr.rb,并且位于以下位置rails自动加载(例如,app / models目录或(取决于rails和您的配置)lib /目录)。

请注意,您的问题最好是“什么是未初始化的常量ApplicationHelper :: SomeClassName告诉我?”。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章