ruby on rails - Rake task - undefined method -
i tinkering way creating rake task grabs amount of checkins given page throw facebook-graph. usign koala gem , rails.
i creating rake task:
task :get_likes => :environment require 'koala' # grab first user in database user = user.first # loop throw every school & , phone call count_checkins school.columns.each |column| user.facebook.count_checkins(column.name, user) end end # count every school else homecoming 0 def count_checkins(name, u) = u.facebook.fql_query('select checkins page name = "' + name + '"') if a[0].nil? homecoming 0 else homecoming b = a[0]["checkins"] end end # initialize connection facebook graph def facebook @facebook ||= koala::facebook::api.new(oauth_token) end
but error:
private method `count_checkins' called #<koala::facebook::api:0x007fae5bd348f0>
any ideas or improve way code rake task awesome!
check total error here: https://gist.github.com/shuma/4949213
can't format in comment, i'll set in answer. set next user model:
# count every school else homecoming 0 def count_checkins(name) = self.facebook.fql_query('select checkins page name = "' + name + '"') if a[0].nil? homecoming 0 else homecoming b = a[0]["checkins"] end end # initialize connection facebook graph def facebook @facebook ||= koala::facebook::api.new(oauth_token) end
then alter rake task to:
task :get_likes => :environment require 'koala' # grab first user in database user = user.first # loop throw every school & , phone call count_checkins school.columns.each |column| user.count_checkins(column.name) end end
that way count_checkins defined on user model, rather trying modify class within koala -- , aren't duplicating work having pass around more user , facebook parameters necessary.
ruby-on-rails ruby ruby-on-rails-3 rake koala
No comments:
Post a Comment