Irrelevant syntax issue in apiblueprint - web-services

So I've been designing this REST API using apiary.io and I'm almost done.
There is this syntax issue that I get which doesn't make sense at all.
I have a [GET] action for a specific resource But It seems like apiary confuses it with a [GET] action for another resource and says
Action with method 'GET' already defined for resource '/api/quotes?{sq}&{author_id}&{ratingrange}&{quoteidrange}&{authorratingrange}&{authoridrange}'
Here is the API link :
https://app.apiary.io/kalematie/editor
the syntax issue is in line 987
I would like to know whether I'm doing something wrong or there's a bug in the tool.
Thanks in advance.

Related

RSpec: Problems converting to the new "allow" syntax for mocks/stubs

I am trying to learn rspec and apply what I am learning to an existing rails app.
I am trying to create a mock of a user called "current_user"
I have basically taken this line of code
controller.stub(:current_user).and_return(build_stubbed(:user))
and placed it before my tests (all of which require a current_user to be defined)
This works. But
I know that this syntax is deprecated and I should be using
allow().to receive().and_return()
syntax but I can't seem to convert it to the new syntax and get it to work.
I tried
user = double("user")
allow(user).to receive(:current_user).and_return(build_stubbed(:user))
without success. I reality I have no idea what I am doing with this and need to be pointed in the right direction. I have looked extensively for an answer but I suspect this is too basic.
Would appreciate some guidance.
Currently, you're stubbing the current_user method for your controller variable. In your new syntax example, you've put the stub on the user double object.
Without knowing more about build_stubbed, I would expect it to look like:
allow(controller).to receive(:current_user).and_return build_stubbed(:user)

Custom Audience Opt-Out Method

I'm working on some opt-out functionality and trying to use this endpoint:
https://graph.facebook.com/act_{ad_account_id}/usersofanyaudiences
from the docs here: https://developers.facebook.com/docs/reference/ads-api/custom-audience-targeting/#opt-out
I've been using a POST with a single ID in the body, something like this: users=[{"id":"THIS_ID_HERE"}]
I keep getting the same error:
[Error: {"message":"Unknown path components: /usersofanyaudiences","type":"OAuthException","code":2500}]
Is a POST the right method to use? Something else I might be doing wrong here?
Apologies - looks like the documentation was out of date, the proper end point is https://graph.facebook.com/act_{ad_account_id}/usersofanyaudience (singular). We have updated the documentation.

How to implement "find or create" with Ember Data

Currently I'm hitting a wall with Ember Data loading some data which might exist or might not. If a record does not exist, the web application should create it.
Simple use case: documenting an inventory. If an article does not exist, a new article should be added. If it does exist, then the employee can immediately use the information.
I suspect the adapter find() method to be the source of this problem. It cannot handle a 404 not found error and passing an empty result does not work either.
Probably I am overlooking something trivial, as 'find or create' is quite a regular pattern. Please help...
See this issue, or here's the solution:
findOrCreate: (type, properties)->
#store.find(type, properties.id).then null, (reason)=>
if reason.status == 404
record = #store.recordForId(type, properties.id)
record.loadedData()
record.setProperties(properties)
record.save()
else
throw reason
see #296
Already a bug report for this

App.get('router').send causing this error Uncaught TypeError: Cannot redefine property: __ember1346884664897

Anyone have any ideas why I'm getting this error:
Uncaught TypeError: Cannot redefine property: __ember1346884664897
when calling:
App.get('router').send('tags')
I'm making the call from one of my views, the router is in the correct state, and as far as I can tell I'm doing everything by the book.
Would really appreciate any ideas...
Created a gist that might help explain things a little better. https://gist.github.com/3647288
App.router.send('something') will look for a function named something in your current state, but you are trying to use route name there. You should have something like showTags in you router and use App.router.send('showTags').
Head to docs http://docs.emberjs.com/#doc=Ember.Router&src=false and look at the part Transitions Between States
I had this problem when I named an action and a state the same way. Perhaps you have the same thing now.

Why is my Ember.Router giving this TypeError?

I'm using Ember built from git master. My RouteManager is not complex, but when I try to start my app, I get this error:
Uncaught TypeError: Property '1' of object , is not a function
Following the trace indicates that this is happening on the app's initialization.
This jsfiddle shows the problem, although you'll have to look in the javascript console to see the error message. My actual router will be more complex than this, but I've pared it down to the bones to try to eliminate potential error sources.
You need to update your version of Ember Data to the latest version from master, as the injection API changed.
Here is a fiddle which "works".
http://fiddle.jshell.net/Sly7/ZySzK/
I pick up an ember-data resource from another fiddle I found on stackoverflow.
The way of populating the arraycontroller is weird. Usually you pass the context in the connectOutlet method of the controller, by specifying a context (in your case, it should be Sylvius.Section.find() )
I don't know why, but doing this, I have the error 'Sylvius.Section has no method find'... perhaps an other mess due to ember-data/emberjs bad version.