On 16 Jun 2008, at 23:03, Sean Cribbs wrote:

Rails 2.0.x allows you to use hashes in conditions, even for nil attributes, so you could refactor that like so:

count(:conditions => {:unsubscribed_at => nil, :subscriber_list_id => subscriber_list.id })

Thanks for the tip Sean. I'll do that right away.

Drew




Sean

Andrew Neil wrote:
Nate,

Did you make any headway on this?

Try running this in script/console:

>> s = Page.find_by_class_name("SubscriberListPage")
=> #<SubscriberListPage id: 11, title: "Newsletter", slug: "newsletter", breadcrumb: "Newsletter", class_name: "SubscriberListPage", status_id: 100, parent_id: 1, layout_id: nil, created_at: "2008-06-15 14:38:39", updated_at: "2008-06-15 14:38:39", published_at: "2008-06-15 15:38:39", created_by_id: nil, updated_by_id: nil, virtual: false, lock_version: 0, description: nil, keywords: nil>
>> Subscriber.count_active_subscribers(s)
=> 0

I'm afraid I can't reproduce the error, and I am also using Radiant 0.6.7, Rails 2.0.2. What database are you using? I've only tested on MySQL.

Looking at the definition of the method count_active_subscribers, I'm wondering if it is MySQL specific:

   def count_active_subscribers(subscriber_list)
count(:conditions => ["unsubscribed_at IS ? AND subscriber_list_id = ?", nil, subscriber_list.id])
   end

I'm not certain whether this would work with, say SqlLite. Even so, the error message says undefined method, which is surprising since the method is defined in the Subscriber model.

Drew

vendor/extensions/subscriber_lists/app/views/subscribers/ index.html.erb
where line #15 raised:

undefined method `count_active_subscribers' for #<Class: 0x7fcb342a30d0>

Extracted source (around line #15):

12: <% @lists.each do |list| %>
13:   <tr>
14: <td><a href="<%= url_for :action => 'list', :id => list.id %>"><span class="title"><%= list.title %></span></a></td>
15:   <td><%= Subscriber.count_active_subscribers(list) %></td>
16: <td><%= link_to "Edit page", page_edit_path(:id => list.id) %></td> 17: <td><%= link_to "Export", :action => "export", :id => list.id %></td>
18:   </tr>

###

I have huffed and I have puffed, but I cannot figure out how why it isn't working. Do you have any thoughts?

Radiant 0.6.7, Rails 2.0.2


_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to