5

我得到无法转储匿名类错误。

我的模型中有以下方法。

 def seating_for(active)
   ln = cache(col("lu", active)) do
    self.seat_list_for(active).where(seat_id: self.seat_entries)
 end

 def seat_list_for(active)
   ex_id = Exc.id_by_symbol(active)
   self.row.exe.seats.where(ex_id: exc_id).first.seat_alloc_mem
 end

我正在尝试缓存 ln。我收到一个错误。无法弄清楚是什么问题。

 can't dump anonymous class #<Module:0x00000007ab6088>
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/activesupport-3.2.14/lib/active_support/cache.rb:561:in `dump'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/activesupport-3.2.14/lib/active_support/cache.rb:561:in `initialize'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/redis-activesupport-3.2.4/lib/active_support/cache/redis_store.rb:34:in `new'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/redis-activesupport-3.2.4/lib/active_support/cache/redis_store.rb:34:in `block in write'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/activesupport-3.2.14/lib/active_support/cache.rb:520:in `instrument'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/redis-activesupport-3.2.4/lib/active_support/cache/redis_store.rb:33:in `write'
 /home/#/.rvm/gems/ruby-2.0.0-p0@anon-ui/gems/activesupport-3.2.14/lib/active_support/cache.rb:299:in `fetch'
 /home/#/user/projects/app/#/lib/lib_utility.rb:15:in `cache'
 /home/#/user/projects/app/#/app/models/smthng.rb:566:in `seating_for'

lib/lib_utility.rb

module LibUtility
  module ClassMethods
    def col(p, l)
     //smthng
    end

   def cache(l, options={}, &b)
     Rails.cache.fetch(l, expires_in: 50.minutes, &b)
   end
  end

  def self.included(receiver)
    receiver.extend ClassMethods
  end

end

需要指导吗??


母版页和内容占位符中的 Javascript 验证

我正在使用 asp.net。我在主页面中有一个登录表单。我在 Master Page 中为此编写了 Javascript 验证功能。

<table>
    <tr>
        <td>Username:></td>
        <td><asp:TextBox runat="server" id="txtUsername"/></td>
        <td>Password:></td>
        <td><asp:TextBox runat="server" id="txtPassword"/></td>
        <td>Username:></td>
        <td><asp:Button runat="server" id="btnLogin" Text="Login"/></td>
    </tr>
</table>

我也在内容占位符中有发送电子邮件表单。我在 Content Place Holder 中为此编写了 Javascript 验证函数。

 <table>
    <tr>
        <td>To:></td>
        <td><asp:TextBox runat="server" id="txtTo"/></td>
        <td>Password:></td>
        <td><asp:TextBox runat="server" id="txtEmail"/></td>
        <td>Username:></td>
        <td><asp:Button runat="server" id="btnSend" Text="Send"/></td>
    </tr>
 </table>

我的问题是当我单击 btnSend 按钮时,正在验证登录表单?

编辑: 解决方案: 问题是我对母版页和内容占位符使用相同的验证函数名称。我在母版页中更改了验证函数名称,这解决了问题

4

1 回答 1

18

问题是您尝试缓存ActiveRecord关系集合。这是不可能的。如果要缓存查询,则需要先将其设为数组

def seating_for(active)
  cache(col("lu", active)) do
    self.seat_list_for(active).where(seat_id: self.seat_entries).to_a
  end
end
于 2014-03-05T23:58:23.227 回答