Giter VIP home page Giter VIP logo

motion-resource's People

Contributors

andyw8 avatar fearoffish avatar joshsmith avatar mnin avatar nathanstitt avatar tkadauke 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar

motion-resource's Issues

Nested resouces

I have the following classes:

class Market < MotionResource::Base
  has_many :market_days
end

class MarketDay < MotionResource::Base
  belongs_to :market
  self.member_url = "markets/:market_id/market_days/:id"
end

And I'm trying to fetch a particular market_day through the market_days association:

market.market_days.find(day.date) do |market_day|
  ...
end

but this fails with:

undefined method `call' for "2013-06-16":String (NoMethodError)
  from find.rb:61:in `request_block_call:'
  from find.rb:18:in `block in fetch_member:'
  from requests.rb:69:in `block in http_call:'
  from query.rb:358:in `call_delegator_with_response'

("2013-06-16" is the ID of the date I'm trying to fetch).

Does motion-resource support this? Do I have the syntax wrong?

Relationships not translating urls correctly.

class User < MotionResource::Base
  attr_accessor :id
  attribute :full_name, :abbreviated_name, :avatar50, :avatar70, :points_this_week, :points_today, :total_points, :monthly_points
  has_many :hidukens

  self.collection_url = "users"
  self.member_url = "users/:id"

end
class Hiduken < MotionResource::Base
  attr_accessor :id
  attribute :user_id, :points, :multiplier
  belongs_to :user

  self.collection_url = "users/:user_id/hidukens"
  self.member_url = "users/:user_id/hidukens/:id"

end
def my_load_data
    User.find(app_delegate.user_id) do |my_user, response|
      if response.ok?
        my_user.hidukens do |h|
          puts h.inspect
        end
      end
    end

  end

Makes a call to my api

/api/v1/users/:user_id/hidukens.json"

instead of

/api/v1/users/5/hidukens.json"

Use AFNetworking?

What would you think of using AFNetworking instead of bubble-wrap? It would add a dependency, but give much more flexibility

Attribute in Readme

Just a suggestion, I would include somewhere in the Readme the use of attribute

For example:

class Shape
  attribute :color
end

It was a little confusing because I thought attr_accessor was the same as attribute.

Thanks!

Collection_url bug

In your examples, if I add collection_url to tag, I get an error.

Tag:

class Tag < MotionResource::Base
  attr_accessor :name

  belongs_to :color
  collection_url "tags"
end

Error:

2013-03-16 11:11:32.905 Colr[62943:c07] *** Terminating app due to uncaught exception 'ArgumentError', reason: 'wrong number of arguments (1 for 0) (ArgumentError)

Logging actions

Hi @tkadauke

I'm having problems using your gem. I've everything set up, just like the readme tells me:

class Client < MotionResource::Base

  MotionResource::Base.root_url = "http://localhost:3000/api/"

  # Include the MotionModel
  include MotionModel::Model
  include MotionModel::ArrayModelAdapter
  include MotionModel::Validatable

  # Define the attribute accessors
  attr_accessor :id
  attribute :name

  # Define the columns of this model
  columns name: :string

  # Validate the client model
  validate :name, presence: true

  # Define the URL's for this resource
  self.collection_url = "client"
  self.member_url = "client/:id"
end

But it seems there's no request send to the API. For your convenience my app_delegate.rb:

# app_delegate.rb
    @client = Client.create( name: 'Your awesome client' )
    p @client

Cheers!

Class to inherit from.

In your examples, the Tag model inherits from "MotionResource::Base", however, in your readme is says "RemoteModule::RemoteModel"

No :id parameter given for User.instantiate

I'm getting the following error:

Terminating app due to uncaught exception 'ArgumentError', reason: 'base.rb:27:in `instantiate:': No :id parameter given for User.instantiate (ArgumentError)`

Here's the User:

class User < MotionResource::Base
  attr_accessor :id

  self.collection_url = "users"
  self.member_url = "users/:id"
  self.default_url_options = {
    :payload => {
      'token' => "#{App::Persistence['facebook_access_token']}"
    }
  }
end

My JSON response looks like the following:

{
  "success": true,
  "user": {
    "id": 13,
    "name": "Josh Smith",
    "email": "[email protected]",
    "first_name": "Josh",
    "last_name": "Smith"
  }
}

Could this have something to do with not having the id in the root object? Am I doing something else obviously wrong?

Thanks!

undefined method `class_attribute' for MotionResource::Base:Class

I'm trying to add motion-resource to my project, but it fails at runtime with:

*** Terminating app due to uncaught exception 'NoMethodError', reason: 'undefined method `class_attribute' for MotionResource::Base:Class (NoMethodError)

Should it work with RubyMotion 2?

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.