ruby-on-rails-3

'Cannot call API on behalf of this user' on FB API call

。_饼干妹妹 提交于 2020-01-05 01:40:43
问题 I am having trouble with facebook API call. I am using Koala for server side api call but recently came into issue making api call. So I tried to bypass koala call and did raw api http call using call but to no avail. When I do curl from development machine it works fine. curl "https://graph.facebook.com/me?oauth_token=my_token It returns profile details, but the same thing done from production machine, it's throwing the exception {"error":{"message":"Cannot call API on behalf of this user",

retrieving username with find_by_id(comment.user_id).name not working

半腔热情 提交于 2020-01-04 20:38:40
问题 I'm trying to retrieve a user name to insert into a comment on a blog post using rails if I use <%= comment.user_id %>" it will give me an id but if I try and retrieve the user then call the name it return nil class <%= User.find_by_id(comment.user_id).name %>" why is this not working if I leave .name off it returns a space in memory. #<User:000x00000182fe48> 回答1: Most likely, the dynamic finder is getting confused by the id and is returning the (Ruby) object's id (i.e. object_id ) instead of

retrieving username with find_by_id(comment.user_id).name not working

☆樱花仙子☆ 提交于 2020-01-04 20:36:36
问题 I'm trying to retrieve a user name to insert into a comment on a blog post using rails if I use <%= comment.user_id %>" it will give me an id but if I try and retrieve the user then call the name it return nil class <%= User.find_by_id(comment.user_id).name %>" why is this not working if I leave .name off it returns a space in memory. #<User:000x00000182fe48> 回答1: Most likely, the dynamic finder is getting confused by the id and is returning the (Ruby) object's id (i.e. object_id ) instead of

Deep association and Sphinx index with Thinking Sphinx?

大憨熊 提交于 2020-01-04 16:01:06
问题 Currently I have the ff table: Teams id Team_User team_id, user_id Users user_id Item id team_id And the ff. model: Team has_and_belongs_to_many :users User has_and_belongs_to_many :teams Item belongs_to :audit_team, :class_name => "Team", :foreign_key => "team_id" Why I am trying to archive is to get Sphinx to index all the user_id that associate with Item and I came up with this index definition: define_index do has audit_team.users(id), :as => :team_users end I am not sure if this is

Deep association and Sphinx index with Thinking Sphinx?

我与影子孤独终老i 提交于 2020-01-04 16:00:50
问题 Currently I have the ff table: Teams id Team_User team_id, user_id Users user_id Item id team_id And the ff. model: Team has_and_belongs_to_many :users User has_and_belongs_to_many :teams Item belongs_to :audit_team, :class_name => "Team", :foreign_key => "team_id" Why I am trying to archive is to get Sphinx to index all the user_id that associate with Item and I came up with this index definition: define_index do has audit_team.users(id), :as => :team_users end I am not sure if this is

Globbing doesn't work with Minitest - Only one file is run

别来无恙 提交于 2020-01-04 15:14:54
问题 I have placed all my specs in specs/*.rb . However, when I run Minitest with ruby spec/**/*_spec.rb , only one file is run. What gives? 回答1: This is not minitest specific, but Ruby. You are effectively running a ruby program which knows nothing about the program being run. Ruby does not support running multiple files at once afaik, so if you want to get a similar result you could try something like: for file in spec/**/*_spec.rb; do ruby $file; done UPDATE : for what you want you should

Using Postmates API in a rails app with HTTParty

隐身守侯 提交于 2020-01-04 14:20:59
问题 I've been working on integrating Postmates with my ecommerce rails application for on demand deliveries. I've built a controller and view for testing purposes and configured it in my routes file (built in my dev environment). For reference, here is the documentation from Postmates: docs and here is a technical blogpost: blog Routes file: resources :postmates do member do post 'get_delivery' end end The controller: require 'httparty' require 'json' class PostmatesController <

Handle exception in Sidekiq 3 jobs

落花浮王杯 提交于 2020-01-04 13:26:13
问题 I am using Sidekiq 3 in my ruby on rails 3.2 application. How can I handle exception in Sidekiq jobs without plugin (for example: Honeybadger, Airbrake, Rollbar, BugSnag). I want to catch exception that occurs in the job. 回答1: Bugsnag actually comes with built-in support for catching errors in both Sidekiq 2 and 3, so it will automatically detect any exceptions in your sidekiq jobs! 来源: https://stackoverflow.com/questions/24269388/handle-exception-in-sidekiq-3-jobs

Rails 3 ActiveRecord where clause where id is set or null

∥☆過路亽.° 提交于 2020-01-04 10:42:52
问题 I have an ActiveRecord, Annotation, with two columns: user_id and post_id, which can be null. An annotation with null user_id and post_id are "global" annotations that are applicable to all posts across all users. I would like to retrieve all annotations associated with a particular user's post AND all global annotations. In MySQL, the SQL command would be select * from annotations where (user_id = 123 and post_id = 456) or (user_id is null and post_id is null) In Rails 3, what is best way to

Rails 3 ActiveRecord where clause where id is set or null

偶尔善良 提交于 2020-01-04 10:42:16
问题 I have an ActiveRecord, Annotation, with two columns: user_id and post_id, which can be null. An annotation with null user_id and post_id are "global" annotations that are applicable to all posts across all users. I would like to retrieve all annotations associated with a particular user's post AND all global annotations. In MySQL, the SQL command would be select * from annotations where (user_id = 123 and post_id = 456) or (user_id is null and post_id is null) In Rails 3, what is best way to