[Nitro] is Orderable weird exception
aurelianocalvo at yahoo.com.ar
Mon Jul 9 09:31:32 EDT 2007
Debugging a little I've found that the code defined with before
:og_insert does not run when an entity is inserted (at least on the
test I did here). It makes the following code unreachable:
#Line 64 og/lib/og/model/orderable.rb
before :og_insert do
Because of it, the position is not set on insertion :(.
How can I fix it?
> Orderable is not working :(.
> It creates the position row in the database but it does not fill it.
> class Question
> attr_accessor :text, String
> belongs_to :survey
> is Orderable, :scope => :survey
> class Survey
> attr_accessor :name, String
> has_many :questions , :list => true, :order => 'position DESC'
> Offending spec:
> describe Question, "new" do
> before( :all ) do
> @your_car = Survey.create_with( :name => "your car")
> it "positions should be set" do
> @like_your_car = Question.create_with( :text => "Do you like your car?")
> @your_car.questions << like_your_car
> @your_car_color = Question.create_with( :text => "What is the
> color of your car?")
> @your_car.questions << your_car_color
> @like_your_car.position.should == 1 # position == null both here
> and in the database.
> @your_car_color.position.should == 2
> after( :each ) do
> after( :all ) do
More information about the Nitro-general