[Nitro] is Orderable weird exception

Aureliano Calvo 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
    add_to_bottom()
  end

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.
>
> Models:
> class Question
>   attr_accessor :text, String
>   belongs_to :survey
>   is Orderable, :scope => :survey
> end
>
> class Survey
>   attr_accessor :name, String
>   has_many :questions , :list => true, :order => 'position DESC'
> end
>
> Offending spec:
>
> describe Question, "new" do
>
>   before( :all ) do
>     @your_car = Survey.create_with( :name => "your car")
>   end
>
>   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
>   end
>
>   after( :each ) do
>     Question.delete_all
>   end
>
>   after( :all ) do
>     Survey.delete_all
>   end
> end
>


More information about the Nitro-general mailing list