Update...

Looks like the query is being run twice.

My development log says...

---
Event Load (0.000271)   SELECT * FROM events WHERE (name = 'Celine Dion') LIMIT 1
Event Columns (0.000165)   SHOW FIELDS FROM events

Logger: Found record: Celine Dion

Event Load (0.000187)   SELECT * FROM events WHERE (name = NULL) LIMIT 1
---

For whatever reason it's doing the find twice. Any ideas?

---


On 10/31/06, Rabbit <[EMAIL PROTECTED]> wrote:
event_behavior.rb
---

class EventBehavior < Behavior::Base
 
  register 'Event'
 
  description = %{}
 
  define_tags do
    tag 'event' do |tag|
      if tag.attr['find']
        tag.locals.event = Event.find_by_name(tag.attr['find'])
      end
     
      tag.expand
    end
   
    tag 'event:name' do |tag|
      tag.locals.event.name
    end
  end
 
end


Radiant page:
---

<r:event find="Celine Dion">
  <p><r:event:name /></p>
</r:event>

---

Okay. So, the example above works. However... One seemingly simple change...

event_behavior.rb
---

class EventBehavior < Behavior::Base
 
  register 'Event'
 
  description = %{}
 
  define_tags do
    tag 'event' do |tag|
      tag.locals.event = Event.find_by_name(tag.attr['find'])
      tag.expand
    end
   
    tag 'event:name' do |tag|
      tag.locals.event.name
    end
  end
 
end


---

And everything goes to shit. I get:
You have a nil object when you didn't expect it! The error occured while evaluating nil.name

Hitting refresh gives me a Rails error -- I assume it's because of Radiant's caching.

Since when did evaluation for truth alter the way something behaves?

Help is greatly appreciated.

- Daniel

_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to