hi all
I have a problem trying to do the following:
MyModel.find(:all).find(:first)
it can look weird or unnecesary but this is the short explanation,
extended one is:
I have a helper method, this receives a collection an return some html,
this helper works fine if that collection is an association (has_many)
of a model but doesn’t work if it is a direct find over a model
the error I receive is “LocalJumpError: no block given”
ultra mega extended explanation is:
a model:
class User < ActiveRecord::Base
has_many :requests
end
other model:
class Request < ActiveRecord::Base
def unRequested
find(:all, conditions => {:state => “unrequested”})
end
end
the helper
module ApplicationHelper
def yearsCalendar (collection)
years = collection.find(:all, :select => “YEAR(date_created) AS
years”)
years.each do |y|
html << “
end
end
end
finally at view:
<%= yearsCalendar(User.requests) # WORKS FINE %>
<%= yearsCalendar(Request.unRequested) #WONT WORK , RETURN ERROR:
“LocalJumpError: no block given” %>
any help?, thanks in advance