Useful command line tools
raw1z / amistad Goto Github PK
View Code? Open in Web Editor NEWAdds friendships management into a rails application
Home Page: http://github.com/raw1z/amistad
License: MIT License
Adds friendships management into a rails application
Home Page: http://github.com/raw1z/amistad
License: MIT License
Hi,
I was using this gem and everything was working as expected so far. However, I recently needed to add a polymorphic association in my user model and include Amistad::FriendModel
actually breaks the way Rails is querying the database somehow.
I've created an issue on stackoverflow about it : http://stackoverflow.com/questions/24499383/rails-4-amistad-gem-breaks-polymorphic-association
Any idea why it behave like that?
Hello i am experiencing a problem saving the link between users. I have 2 users in my database and i do the following thing in the rails console
user_one.invite user_two
=> true
user_two.approve user_one
=> true
but when i reload user_one or user_two
and i ask for the friends of this user it returns an empty array
So anyone else having the same issue >? My gemfile has rails 3.1.0.rc5 and "mongoid", ">= 2.0.0.beta.19"
Hello,
Is it possible to handle friendship relations through a Profile model instead of a user model ?
Thanks,
I'm using rails 3.2.5 with activerecord 3.2.5, and ruby 1.9.3
i tried to implement amistad gem for maintaining friendship within my application.
I have added "include Amistad::FriendshipModel" in my user model. but i don't see any methods included in mys user model. I have to know if there is any problem for amistad with activerecord 3.2.5? whether this will work or not with this version of activerecord.
It throws error like:
RuntimeError: Amistad only supports ActiveRecord and Mongoid
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/amistad-0.9.2/lib/amistad/friendship_model.rb:9:in `included'
When i try with my console. any methods from amistad like invite, approve are throwing errors as undefined method "invite"
Please help me
When you add amistad to an existing User when using mongoid and there is already users in the database, you get the following error when calling pending_invited or pending_invited_by:
Document not found for class User with id(s) .
Here's the relevant trace...
mongoid (2.0.0.beta.20) lib/mongoid/contexts/ids.rb:19:in id_criteria' mongoid (2.0.0.beta.20) lib/mongoid/criteria.rb:32:inid_criteria'
mongoid (2.0.0.beta.20) lib/mongoid/criteria.rb:191:in translate' mongoid (2.0.0.beta.20) lib/mongoid/finders.rb:68:infind'
amistad (0.7.3) lib/amistad/mongoid/friend_model.rb:73:in `pending_invited_by'
It's likely because the user document does not yet have any of the friendship documents yet. A check should exist for this, and either halt execution or initialize the missing content.
kindly I need to know any tutorials for these wonderful gem
So basically the database shows up on the page every time i do a listing of friends, invited or pending invites.
My code looks like this
<%= @friends.each do |friend| %>
<%= friend.account %>
and the database info look like:
[#<User id: 1, account: "account1", password_digest: "$2a$10$m3epMrV5Hn5pNPZvo5xx5.wma8zYPbbxWgkpKJz5OtL...", email: "[email protected]", created_at: "2015-04-21 02:17:49", updated_at: "2015-04-21 02:17:49">]
Any ideas?
Thx
Hi,
I get the following when I do a current_user.friends
However I have no problem doing a current_user.invited and current_user.invited_by
Im running Rails 3.1.1
I have installed amistad and after the installation when I'm unable to start the server as it giving an error.
/home/mohd.hussain/.rvm/gems/ruby-1.9.3-p484@partyapp/gems/activerecord-3.2.14/lib/active_record/associations.rb:1197:in has_many': wrong number of arguments (3 for 2) (ArgumentError) from /home/mohd.hussain/.rvm/gems/ruby-1.9.3-p484@partyapp/gems/amistad-0.10.2/lib/amistad/active_record_friend_model.rb:14:in
block in module:ActiveRecordFriendModel'
from /h
I'm using ruby - 1.9.3 and rails 3.2.14
What am I doing wrong
I've just gotten started integrating amistad - loving the features and have it all working in the CLI.
I'm attempting to create buttons on user show pages to add a friend however I'm not sure what the form_for would look like.
Currently I have something like
<%= form_for current_user.friend_with @user do |f| %>
<div><%= f.hidden_field :@user.id %></div>
<div><%= f.submit "Invite Friend", :class=> "btn primary" %></div>
<% end %>
This clearly doesn't work, but it's the idea of what I'm trying to do - I want an "Invite Friend" button on a user page that triggers the create method in my FriendshipsController.
Thanks for any help!
Hello,
first of all, thanks for your work, is a nice gem, i'm plaining to use it in several projects im planing.
just playing with it on the console, i find that there are too much querys, heres is an example.
userB.appove(userA)
this method, located at active_record_friend_model (:67) use another method to find if there is a friendship record between these two users "find_any_friendship_with(userA)"
but, under this line, there is another mehod that do the same "invited?(:156)" that also uses "find_any_friendship_with", what about if we just do one query?? maybe the method can just be like this:
def approve(user)
friendship = find_any_friendship_with(user)
return false if friendship.nil?
friendship.update_attribute(:pending, false)
end
i'm new on ruby, maybe i'm missing something....
thanks!!!
Hello. I'm getting a lot of red tests.
https://gist.github.com/2042936
http://travis-ci.org/#!/simi/amistad/jobs/871030
Can anyone confirm?
Hello! I really liked using your gem.
In my project I have 2 models, where I want to use friendship. Is there the way to do so?
Is there any reason why find_any_friendship_with is private? I'm integrating amistad (looking good, so far!) into my application, in which my friendships join table has a foreign key. I'd like be to able to easily access the friendship record. True, I could do it other ways, but the find_any_friendship_with does exactly what I want.
After upgrading from 0.7.5 to 0.9.2 I got this error when calling the friends-method on a user, e.g.
user.friends
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'friendships.friendable_id' in 'where clause': SELECT users
.* FROM users
WHERE ((users
.id
IN (SELECT friendships
.friend_id
FROM friendships
WHERE ((friendships
.friendable_id
= 13 AND friendships
.pending
= 0 AND friendships
.blocker_id
IS NULL))) OR users
.id
IN (SELECT friendships
.friendable_id
FROM friendships
WHERE ((friendships
.friend_id
= 13 AND friendships
.pending
= 0 AND friendships
.blocker_id
IS NULL)))))
it just costed me an hour figuring out how to remove friendships (well i'm still rails noob ;) )
after a look into the source i found out that the method used for removing friendships is not user.remove(friend) but user.remove_friendship(friend)
please update the documentation
Came across an interesting issue today, where approving friendships was failing, complaining that the number of arguments provided was incorrect.
It seems that amistad and devise invitable conflict by both adding the 'invited?' method to the model. Anyone have any good solutions for this, if I absolutely need both gems?
For now, some monkey-patching is letting me work around the issue, but given that I'm overriding 'approve', it's not exactly robust:
In an initialiser:
module Amistad
module ActiveRecordFriendModel
def approve(user)
friendship = find_any_friendship_with(user)
return false if friendship.nil? || friendship_invited?(user)
friendship.update_attribute(:pending, false)
end
alias_method :friendship_invited?, :invited?
end
end
Any suggestions on a better long term solution?
In ActiveRecord::FriendModel, in the instance methods, calling operator + on 2 relations force loading all rows from database to merge the 2 relations.
Exemple: lib / amistad / active_record / friend_model.rb line 68-70:
def friends
self.invited(true) + self.invited_by(true)
end
The friends method returns an Array instead of an ActiveRecord::Relation object and it's not possible anymore to chain any ActiveRecord query method like offset, limit and order.
Is it possible to update the gem and use the method merge from ActiveRecord::SpawnMethods to merge the two Relation objects and get a new one ?
def friends
self.invited(true).merge self.invited_by(true)
end
Hey there! I'm fairly new to rails and trying to implement the amistad gem (using devise). I've it up using the Active Record instructions (and somewhat using this as an example http://keighl.com/post/amistad-friendships-controller/) but am getting the error:
uninitialized constant User::Amistad
and this line in my User.rb model is highlighted:
include Amistad::Friendships::UserFriendship
Any ideas what I am missing? Thanks.
where is the place to configure something like this:
Amistad.configure do |config|
config.friend_model = 'Profile'
end
after install amistad , restart server , I see a error
wrong number of arguments (3 for 2)
the full trace is
activerecord (3.2.13) lib/active_record/associations.rb:1197:in `has_many'
amistad (0.10.0) lib/amistad/active_record_friend_model.rb:16:in `block in <module:ActiveRecordFriendModel>'
activesupport (3.2.13) lib/active_support/concern.rb:121:in `class_eval'
activesupport (3.2.13) lib/active_support/concern.rb:121:in `append_features'
amistad (0.10.0) lib/amistad/friend_model.rb:6:in `include'
amistad (0.10.0) lib/amistad/friend_model.rb:6:in `block in included'
amistad (0.10.0) lib/amistad/friend_model.rb:5:in `class_exec'
amistad (0.10.0) lib/amistad/friend_model.rb:5:in `included'
app/models/user.rb:5:in `include'
app/models/user.rb:5:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
activesupport (3.2.13) lib/active_support/dependencies.rb:469:in `load'
activesupport (3.2.13) lib/active_support/dependencies.rb:469:in `block in load_file'
activesupport (3.2.13) lib/active_support/dependencies.rb:639:in `new_constants_in'
activesupport (3.2.13) lib/active_support/dependencies.rb:468:in `load_file'
activesupport (3.2.13) lib/active_support/dependencies.rb:353:in `require_or_load'
activesupport (3.2.13) lib/active_support/dependencies.rb:502:in `load_missing_constant'
activesupport (3.2.13) lib/active_support/dependencies.rb:192:in `block in const_missing'
activesupport (3.2.13) lib/active_support/dependencies.rb:190:in `each'
activesupport (3.2.13) lib/active_support/dependencies.rb:190:in `const_missing'
clearance (1.4.0) lib/clearance/configuration.rb:29:in `user_model'
clearance (1.4.0) lib/clearance/session.rb:82:in `user_from_remember_token'
clearance (1.4.0) lib/clearance/session.rb:17:in `current_user'
clearance (1.4.0) lib/clearance/session.rb:48:in `signed_in?'
clearance (1.4.0) lib/clearance/authentication.rb:42:in `signed_in?'
actionpack (3.2.13) lib/abstract_controller/helpers.rb:53:in `signed_in?'
app/views/layouts/application.html.erb:48:in `block (2 levels) in _app_views_layouts_application_html_erb___2299720539167234240_70245686545360'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.2.13) lib/action_view/helpers/tag_helper.rb:95:in `content_tag'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:13:in `menu_group'
app/views/layouts/application.html.erb:47:in `block in _app_views_layouts_application_html_erb___2299720539167234240_70245686545360'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:6:in `block (2 levels) in nav_bar'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:125:in `block in container_div_with_block'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.2.13) lib/action_view/helpers/tag_helper.rb:95:in `content_tag'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:170:in `responsive_div'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:125:in `container_div_with_block'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:117:in `block in container_div'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.2.13) lib/action_view/helpers/tag_helper.rb:95:in `content_tag'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:116:in `container_div'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:5:in `block in nav_bar'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:108:in `block in nav_bar_nav'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:40:in `capture'
actionpack (3.2.13) lib/action_view/helpers/tag_helper.rb:95:in `content_tag'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:107:in `nav_bar_nav'
/Users/shangliang/.rvm/gems/ruby-1.9.3-p547@rails3/bundler/gems/twitter-bootstrap-rails-1d93c5a77049/app/helpers/navbar_helper.rb:4:in `nav_bar'
app/views/layouts/application.html.erb:46:in `_app_views_layouts_application_html_erb___2299720539167234240_70245686545360'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/shangliang/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:436:in `_run__3140304189990479911__process_action__4306410903363589170__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
clearance (1.4.0) lib/clearance/rack_session.rb:10:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__1223353627886605144__call__1698402511737311081__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
request_store (1.1.0) lib/request_store/middleware.rb:8:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/shangliang/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/shangliang/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/shangliang/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
my gemfile is
source 'http://ruby.taobao.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'clearance'
gem 'gon'
gem 'ckeditor'
gem 'paperclip'
gem "twitter-bootstrap-rails",:github=>'seyhunak/twitter-bootstrap-rails',:branch=>'bootstrap3'
gem 'simple_form'
gem 'cancan'
gem 'rolify'
gem "bower-rails", "~> 0.8.3"
gem 'mobile_rails'
gem 'ancestry'
gem 'awesome_nested_set'
gem 'amistad'
I have searched for hours and found two posts:
http://keighl.com/post/amistad-friendships-controller
http://stackoverflow.com/questions/6013720/how-to-use-amistad-gem-in-rails3
Neither of which I can get to work. I would really like to use this gem but cannot figure out how to do so. I have it installed but cant get any further. The two posts seem to have very different approaches, I think?
Is there anything out there for less experienced newer users to get this up and running?
Thanks
Would be good if there was a method for getting everyone you're not friends with. Useful for building a search.
I am planning to use this gem in my application for friendship management.
One feature that will make this gem really awesome for me is adding support for inviting friends from external websites like gmail, Facebook etc.
I am planning to fork this gem and merge it back once the development is complete with this feature.
I am planning to use contacts or blackbook gem for adding this functionality.
Before starting the development I would like to discuss about the requirements for this feature with the community. Anybody interested in this feature that want to collaborate with me regarding this?
I'm getting the following warning in my application:
DEPRECATION WARNING: The following options in your User.has_many :pending_invited declaration are deprecated: :conditions. Please use a scope block instead. For example, the following:
has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
I installed Amistad as per the directions, ran the generator, the migration, and in my rails app, its working.
But, I wanted to run the Spec tests to confirm. So, following the instructions, I went to the gem directory and ran the spec test:
smith@lilone:~/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/gems/1.9/gems/amistad-0.7.3$ rake spec:activerecord
(in /home/smith/.rvm/gems/ruby-1.9.2-p0/gems/amistad-0.7.3)
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
/home/smith/.rvm/rubies/ruby-1.9.2-p0/bin/ruby -S bundle exec rspec --format Fuubar "./spec/activerecord/activerecord_friend_model_spec.rb" "./spec/activerecord/activerecord_friendship_model_spec.rb"
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Could not find gem 'mongoid (~> 2.0.0.rc.7, runtime)' in any of the gem sources.
rake aborted!
ruby -S bundle exec rspec --format Fuubar "./spec/activerecord/activerecord_friend_model_spec.rb" "./spec/activerecord/activerecord_friendship_model_spec.rb" failed
(See full trace by running task with --trace)
Any tips on getting the tests working?
Thanks!
user.friend_ids give me these error
NoMethodError: undefined method `friend_ids' for #<User
I am using latest version 0.9.2
If I use bundle install i will install the gem version 0.7.5 (gem 'amistad'), if instead I pull directly from the git, nothing will be installed.
I don't get then how update to the version 0.8.0.
Any explanations?
Thanks
Running PostgreSQL, after upgrading to 0.9.x there's been major spikes on our db server,
with average response times running well into the 2seconds.
Here's some of the EXPLAIN's:
duration: 409.997 ms statement: SELECT 1
duration: 1268.868 ms statement: SELECT "users".* FROM "users" WHERE (("users"."id" IN (SELECT "friendships"."friend_id" FROM "friendships" WHERE (("friendships"."friendable_id" = 16190 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL))) OR "users"."id" IN (SELECT "friendships"."friendable_id" FROM "friendships" WHERE (("friendships"."friend_id" = 16190 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL)))))
duration: 1210.892 ms statement: SELECT "users".* FROM "users" WHERE (("users"."id" IN (SELECT "friendships"."friend_id" FROM "friendships" WHERE (("friendships"."friendable_id" = 16017 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL))) OR "users"."id" IN (SELECT "friendships"."friendable_id" FROM "friendships" WHERE (("friendships"."friend_id" = 16017 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL)))))
duration: 1053.002 ms statement: SELECT "users".* FROM "users" WHERE (("users"."id" IN (SELECT "friendships"."friend_id" FROM "friendships" WHERE (("friendships"."friendable_id" = 77299 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL))) OR "users"."id" IN (SELECT "friendships"."friendable_id" FROM "friendships" WHERE (("friendships"."friend_id" = 77299 AND "friendships"."pending" = 'f' AND "friendships"."blocker_id" IS NULL)))))
After reverting to f436251
all seems to be well again
I suppose some of it could be appointed to Query caches etc needing to catch up, but the issue might be terminal.
Perhaps some extra indexes are required?
In any case, I had to revert because our production app was unresponsive.
Hello , I am using amistad now. It is a nice gem but i can add a friend many times. Can you show me a way to avoid it?
this is my link to add friends , I could avoid self friendship. :
<% unless current_user == @user %>
<%= link_to "Arkadaşlarıma Ekle", friends_path(:user_id => @user), :method => :post,class: "btn btn-large btn-primary" %>
<%end %>
I am using Rails 3.0.4 and I added the gem like this:
gem "amistad" # Gemfile
installed and migrated
include Amistad::FriendModel # user.rb
but if I use any method (like 'friend_with?' or 'friends') I am getting this error:
undefined method `attribute_condition' for #Class:0x00000105a8dda0
hi,
i wanted to paginate the friends list. but it does not work. here is my code:
current_user.friends.paginate(:page => params[:page])
it gives an error:
undefined method `paginage' for #Array:0x00000102df2ca0
pagination works for for pending_invited and pending_invited_by
how can we paginate the friends?
As described, you can get the list of users that a user blocked by current_user.blocked
.
Is there any way to get the list of users who blocked a user like: current_user.blocked_by
?
I tried to implement it but I failed. Is there any tricky way to do so?
The invited_by?
and invited?
methods aren't working for me because of this line:
friendship.friendable == user
For some reason when I access a User instance via the association, even though I get something back which appears to be the same class, but isn't, iow (assuming the friendable ID is 1):
User.find(1) == friendship.friendable # false!
This is under Webrick, Rails 3.0.10, Amistad 0.8.
The most bizarre thing is that it works in the Rails console just fine, and it works in Webrick ONCE before failing.
I hesitated to post this because I am clearly insane, but it's also 100% reproducible.
hi
is possible to paginate friends or hava a search in friends?
When you add amistad to an existing User when using mongoid and there is already users in the database, you get the error:
Document not found for class User with id(s) .
Here's the relevant trace...
mongoid (2.0.0.beta.20) lib/mongoid/contexts/ids.rb:19:in id_criteria' mongoid (2.0.0.beta.20) lib/mongoid/criteria.rb:32:in
id_criteria'
mongoid (2.0.0.beta.20) lib/mongoid/criteria.rb:191:in translate' mongoid (2.0.0.beta.20) lib/mongoid/finders.rb:68:in
find'
amistad (0.7.3) lib/amistad/mongoid/friend_model.rb:73:in `pending_invited_by'
It's likely because the user document does not yet have any of the friendship documents yet. A check should exist for this, and either halt execution or initialize the missing content.
In the README documentation, the line saying
db:migrate
after "It also creates a new migration for the friendship model so don't forget to migrate your database" should read
rake db:migrate
Can you please show me the process of rejecting a friend request that needs approval.
I can only find the code for accepting the request.
Hi,
There's a conflict where devise_invitable and amistad both use an invited? method name. Has anyone found, or could anyone think of a workaround?
I'm just starting to get to use Amistad with Mongoid and I'm finding that current_user.invite(@user) is not saving to the Mongo. I've done this in the console and in the Rails application, which I've determined that the method does work, as the method returns true, but the data does not persist. Has anyone else had this problem? My mongo db does work. I've saved all sorts of data with it, but the Amistad friend methods are not.
Here's some of the log output after the .invite() is run. I also did a current_user.save() just to make sure that I could see Mongo output a save
MONGODB yansn_development['system.namespaces'].find({})
MONGODB yansn_development['users'].find({:_id=>BSON::ObjectId('4f8b100dbf0d820513000007')}).limit(-1).sort([[:_id, :asc]])
MONGODB yansn_development['users'].find({:_id=>BSON::ObjectId('4f8b0fd2bf0d82055b000001')}).limit(-1).sort([[:_id, :asc]])
MONGODB yansn_development['users'].update({"_id"=>BSON::ObjectId('4f8b100dbf0d820513000007')}, {"$set"=>{"last_name"=>"hamilton123", "updated_at"=>2012-04-15 19:06:21 UTC}})
Shouldn't there be a save for the invite() method?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.