Coder Social home page Coder Social logo

pilha's People

Contributors

dlt avatar michaelbarton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pilha's Issues

Ruby's first and count methods don't work on returned collection

So say I do:

q = Question.find_by_user_id(91970)

It returns a long list of stuff,

but if I do:

ruby-1.9.2-p0 > q.count
=> nil
ruby-1.9.2-p0 > q.first
=> nil

At first I thought it was maybe a Ruby 1.9.2 issue, but then I tried it in 1.8.7 and am getting the same issue.

How do I iterate through a collection and get Ruby's array methods to work?

The irony is, that you seem to have used .first in the library of Pilha, so not sure what's happening here.

How do I use Ruby or Rails methods on returned collections?

how I access each of the elements?

For instance:

@questions = Question.find_by_user_id(params[:id], :body => true, :pagesize => 10)

When I do:

@questions.first

It returns blank.

Am I missing something?

I also tried sorting the results, but it is giving me a problem.

I did this in my controller:

@questions = Question.find_by_user_id(params[:id]).order("created_at ASC")

And it produced this error:

undefined method `order' for #<OpenStruct total=254, page=1, pagesize=30, questions=[#<StackExchange::StackOv

Basically, a lot of the regular Rails stuff that I am trying, are giving me problems.

What am I doing wrong? Or is all of this part of the OpenStruct issue?

Edit 1:

Btw, the same applies to other regular Rails functions, e.g.:

@questions = Question.find_by_user_id(params[:id]).limit(5)

Throws the error:

undefined method `limit' for #<OpenStruct total=254, page=1, pagesize=30, questions=[#<StackExc

The struct method 'accept_rate' doesn't work - for User object

ruby-1.9.2-p0 > u
=> #<StackExchange::StackOverflow::User:0x00000100e63358 @struct=#<OpenStruct user_id=91970, user_type="registered", creation_date=1239946368, display_name="marcamillion", reputation=1415, email_hash="64aa7d1e0eb006175565adb0a47a4452", age=28, last_access_date=1322958915, website_url="http://marcgayle.com", location="Jamaica", about_me="<p>Geek that loves business &amp; tech.</p>\n", question_count=253, answer_count=30, view_count=315, up_vote_count=316, down_vote_count=4, accept_rate=87, association_id="530c4d1d-a273-401d-9df9-31c08e230fd0", user_questions_url="/users/91970/questions", user_answers_url="/users/91970/answers", user_favorites_url="/users/91970/favorites", user_tags_url="/users/91970/tags", user_badges_url="/users/91970/badges", user_timeline_url="/users/91970/timeline", user_mentioned_url="/users/91970/mentioned", user_comments_url="/users/91970/comments", user_reputation_url="/users/91970/reputation", badge_counts={"gold"=>0, "silver"=>9, "bronze"=>28}>> 
 ruby-1.9.2-p0 > u.accept_rate
 NoMethodError: undefined method `accept_rate' for #<StackExchange::StackOverflow::User:0x00000100e63358>
from (irb):33

Getting undefined method NilClass

Hi All,
I am using your pilha to talk with StackOverfow site in my app I am getting the following exception. Kindly help to solve that issue.

rake aborted!
undefined method request' for nil:NilClass c:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/active_support/whiny_ nil.rb:52:inmethod_missing'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/base.rb:1
7:in request' c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/question. rb:15:inall'

Getting undefined method NilClass

Hi All,
I am using using the following pilha code ,

StackExchange::StackOverflow.config do |options|
options.api_key = 'My Key'
end
questions = StackExchange::StackOverflow::Question.all(:tagged => 'math', :body => true)

I am getting the following exception.

rake aborted!
undefined method request' for nil:NilClass
c:/ruby187/lib/ruby/gems/1.8/gems/activesupport-2.3.10/lib/active_support/whiny_
nil.rb:52:inmethod_missing'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/base.rb:1
7:in request'
c:/ruby187/lib/ruby/gems/1.8/gems/pilha-0.2.1/lib/pilha/stack_overflow/question.
rb:15:inall'

Kindly help me out to resolve the issue.

I am executing it in windows machine.

Thanks
Malligarjunan S.

The :options hash seems to be b0rked

The options in the query() don't seem to work....when I pass the options as:

@questions = Question.find_by_user_id(params[:id], :body => true, :page => 2, :pagesize => 10)

It still returns something like:

#<OpenStruct total=254, page=1, pagesize=30, questions=[#<Sta

The more I dig into it, the more it seems that the options are not being passed as parameters in the URL.

When I do this:

    logger.debug(@questions)

This is the result of my params:

    Started GET "/?id=91970" for 127.0.0.1 at 2011-12-05 19:04:26 -0500
    Processing by HomeController#index as HTML
    Parameters: {"id"=>"91970"}

No support for other Stackexchange sites

There is no support for any of the other Stackexchange network sites.

How should this be added? Replicate the StackOverflow parts, just re-name it to the appropriate SE site name, or do something else? I'm open to working on this.

No search method

There is no search method but /search exist in the original api.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.