1.3: compile error on has_many :through append
Reported by Betelgeuse | December 12th, 2010 @ 11:18 AM | in Hobo 1.3 (Rails 3)
Failure/Error: u.friends << f
compile error
/usr/local/lib/ruby/gems/1.8/gems/hobo_fields-1.3.0.pre23/lib/hobo_fields/extensions/active_record/attribute_methods.rb:34: syntax error, unexpected '('
def false; (v=@attributes['false']) && (v.to_i rescue v ? 1 : 0); end
^
/usr/local/lib/ruby/gems/1.8/gems/hobo_fields-1.3.0.pre23/lib/hobo_fields/extensions/active_record/attribute_methods.rb:34: syntax error, unexpected ')', expecting kEND
def false; (v=@attributes['false']) && (v.to_i rescue v ? 1 : 0); end
^
# ./spec/controllers/users_controller_spec.rb:16
class Friendship < ActiveRecord::Base
hobo_model
set_primary_key false
fields do
end
belongs_to :owner, :class_name => 'User', :creator => true
belongs_to :friend, :class_name => 'User'
index [:owner_id, :friend_id], :unique => true
end
class User
has_many :friendships, :foreign_key => 'owner_id'
has_many :friends, :through => :friendships
end
Even if there's an error somewhere in my code it should fail more gracefully.
Comments and changes to this ticket
-
Domizio Demichelis December 12th, 2010 @ 11:52 AM
Even if there's an error somewhere in my code it should fail more gracefully.
I have no idea where the error in your code would be, besides after reading the method that is generating it, I have no idea why that is happening.
Could you isolate the very code that is generating it? If I could switch it on and off I could probably find some clue hopefully in less than one day :-)
Thank you
-
Betelgeuse December 12th, 2010 @ 11:59 AM
Ok so things have started to go wrong with this migration being generated:
create_table :friendships, :primary_key => :false do |t| t.integer :owner_id t.integer :friend_id end
What I should have here is :id => false
-
Betelgeuse December 12th, 2010 @ 12:02 PM
In case it wasn't clear it's the set_primary_key false call that starts to do things off. This way I did get it to generate the right migration:
def self.primary_key nil end
-
Betelgeuse December 12th, 2010 @ 12:07 PM
Testing this without hobo on verbatim rails project:
irb(main):001:0> Foobar.primary_key => "false"
So I guess there's no bug to fix in Hobo in that code would behave unexpectedly. It could just be a bit more graceful in the error it gives.
-
Domizio Demichelis March 27th, 2011 @ 06:07 PM
- State changed from new to wontfix
- Milestone set to Hobo 1.3 (Rails 3)
- Milestone order changed from 5 to 0
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป