• 新发明,婊子不能有朋友 at 2013年01月29日

    各位兄台,结帖。。。。。。

    俺在 好友的档里有一列名是 friend,用于记录互加好友与分组。在关联表时,因为对同一表要关联两次,所以就在 User 的表里加了两行

    has_many :master, :class_name => "Circle", :foriegn_key => "user_id" has_many :friend, :class_name => "Circle", :foriegn_key => "friend"

    所以造成 Circle.friend 无法赋值。

    原以为自己发明了新东西,谁知—— SB 总是一次又一次滴证明自己是一个 SB。

  • 新发明,婊子不能有朋友 at 2013年01月29日

    I am sorry. It because in User with has_many :friend, :class_name => "Circle", :foriegn_key => "friend"

  • 新发明,婊子不能有朋友 at 2013年01月29日

    @lgn21st , Look

  • 新发明,婊子不能有朋友 at 2013年01月29日

    1.9.3-p286 :002 > c = Circle.new => # 1.9.3-p286 :003 > c.friend = "1" ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got String(#78194320) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:in raise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:inreplace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:in writer' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:inblock in define_writers' from (irb):3 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in <main>' 1.9.3-p286 :004 > c.friend = "1".to_i ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got Fixnum(#78191590) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:inraise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:in replace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:inwriter' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:in block in define_writers' from (irb):4 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in' from script/rails:6:in require' from script/rails:6:in

    ' 1.9.3-p286 :005 > c.friend = 1 ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got Fixnum(#78191590) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:in raise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:inreplace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:in writer' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:inblock in define_writers' from (irb):5 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in <main>' 1.9.3-p286 :006 > c.friend = 1111 ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got Fixnum(#78191590) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:inraise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:in replace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:inwriter' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:in block in define_writers' from (irb):6 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in' from script/rails:6:in require' from script/rails:6:in' 1.9.3-p286 :007 > c => # 1.9.3-p286 :008 > c.frind = a NameError: undefined local variable or method a' for main:Object from (irb):8 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in' from script/rails:6:in require' from script/rails:6:in' 1.9.3-p286 :009 > c.frind = "a" NoMethodError: undefined method frind=' for #<Circle:0xa890030> from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activemodel-3.2.9/lib/active_model/attribute_methods.rb:407:inmethod_missing' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/attribute_methods.rb:149:in method_missing' from (irb):9 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in' from script/rails:6:in require' from script/rails:6:in' 1.9.3-p286 :010 > c.friend = "a" ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got String(#78194320) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:in raise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:inreplace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:in writer' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:inblock in define_writers' from (irb):10 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in <main>' 1.9.3-p286 :011 > c.friend = 1 ActiveRecord::AssociationTypeMismatch: User(#89151910) expected, got Fixnum(#78191590) from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/association.rb:204:inraise_on_type_mismatch' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/belongs_to_association.rb:6:in replace' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/singular_association.rb:17:inwriter' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/activerecord-3.2.9/lib/active_record/associations/builder/association.rb:51:in block in define_writers' from (irb):11 from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:47:instart' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in start' from /home/syutran/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.9/lib/rails/commands.rb:41:in' from script/rails:6:in require' from script/rails:6:in'

  • 新发明,婊子不能有朋友 at 2013年01月29日

    冤枉啊,@吕胖子,在下说的句句实言,还望大人明察。 你给它武值,它就报: ActiveRecord::AssociationTypeMismatch: expected, got Fixnum 俺就在武值时加上 to_s,它就 ActiveRecord::AssociationTypeMismatch: expected, got String 改为 friend_id 就安静了。

  • web 敏捷之道,照着实例做一遍,差不多就算入门了。

  • web 敏捷之道,照着实例做一遍,差不多就算入门了。

  • 这个一对多咋办? at 2013年01月28日

    多谢 @chucai 兄指点,高人啊!!

  • Bootstrap - Google 的 UI at 2013年01月28日

    多谢@winnie 兄,我现在所用的可能就是这一款。应该是 twitter 的,而不是 google 的,或着是独立第三方的。

  • 估计在性能和安全方面使很多人怀疑吧? 不是说 twitter 就是 ROR 么?只是听说,twitter 的墙太厚,俺没用过,只是听说而已,不足信。

  • Bootstrap - Google 的 UI at 2013年01月27日

    @ichord 兄台,我说的是 datetimepicker,不是 datepicker。我觉得 twitter 的 datetimepicker 就做的不错,选择日期后继续选择时间。虽然这种控件不多用,一旦用到,还是很纠结的。

  • Bootstrap - Google 的 UI at 2013年01月27日

    可惜没找到 datetimepicker 如果有,我会考虑使用它。

  • Github pages 被墙掉了吗 at 2013年01月21日

    山东联通,github 全部被墙,R 就一个字

  • Markdown 的标题应该是两个==吧 =标题 ==标题 ===标题 ====标题 =====标题 ======标题 (1..99999999999999999999999999999999999999999999999999).each do

  • Github pages 被墙掉了吗 at 2013年01月19日

    不好意思,这个提交回复的按钮点了好多次都没有动弹,想刷新再次提交,谁知就变这样了。八格

  • Github pages 被墙掉了吗 at 2013年01月19日

    被墙是啥麻意思?哦不懂,好高深。 是不是被抢的谐音?网站可以抢吗?今天是你的,明天就可能是他的? 大家不要怕,来个《欧洲野餐计划》,有木有?

  • 大漠沙如雪,支持!

    陈经理,俺的手机上没有 O 键,电话没法打,俺就在这留言吧!

    四年 ROR 经验与一年 ROR 经验咋分呢?ruby-china 的注册日期?

  • 自关联该怎么写? at 2013年01月06日

    controllers def new @category = current_user.categories.new @categories = current_user.categories.all

    respond_to do |format| format.html # new.html.erb format.json { render json: @category } end

    new.html.erb

    <%= f.collection_select :parent_id, @categories, :id, :title,:include_blank => true %>

    报错: NoMethodError in Categories#create

    undefined method `map' for nil:NilClass

    估计是 @categories 不合 collection_select 的要求,大伙给的例子多是 Category.all,那是所有的类,俺想要某个人单独的类。

    搞了一下午,天还没有亮。

  • 自关联该怎么写? at 2013年01月06日

    @doitian 老弟,虽然我搞了个九级英语的证书,但您这个 github 还是让我头肿。Thank you ...

  • 当个农村大学生真辛苦 at 2013年01月06日

    if you not in [富二代] do 辛苦

  • @李滑溜,今天的彩票就不要买了吧

  • 我的那帖:印式英语的帖子好像没了,那个伙计的学英语的热帖也没了。 crontab 30 3 * * * mysqldump -uroot -ppassword "一群傻逼" >/usr/local/的梦话{#date}.sql.bak 可以有

  • 自从俺在生产机的根目录里 chmod 777 -R 以后,俺再也没用 root 登录过生产机。

  • 每次活动都想参加,可惜不在任何地方。

  • 虽然俺只搞到半瓶子 ROR,您这个 offer 很诱人

  • syutran#gmail.com

  • 找到了,呵呵。 就是把 vendor/plugins 下的目录加到 Gemfile 里去,然后把这个 plugins 里的东西清空。 另外,3.2.9 好像不再支持 rhtml 了,要改为 html.erb

  • 多谢三位兄弟。