Thanks, Long.  I really appreciate your help.  Since the app is working
nicely now with the new migration to limit daily connection requests, it is
a matter of writing the Ruby code.  I've asked at railsforum.com for help.
Here is the question..


   1. class ConnectionsController < ApplicationController
   2.
   3.   before_filter :login_required, :setup
   4.   before_filter :authorize_view, :only => :index
   5.   before_filter :authorize_person, :only => [:edit, :update, :destroy]
   6.   before_filter :redirect_for_inactive, :only => [:edit, :update]
   7.
   8.   # Show all the contacts for a person.
   9.   def index
   10.     @contacts = @person.contacts.paginate(:page => params[:page],
   11.                                           :per_page =>
   RASTER_PER_PAGE)
   12.   end
   13.
   14.   def edit
   15.     @contact = @connection.contact
   16.   end
   17.
   18.   def can_request?
   19.
   20.     # table "preferences" has boolean field "limit_requests"
   21.     # table "preferences" has integer field "daily_requests"
   22.     # table "connections" has boolean field "can_request_connection"
   23.     # table "connections" has integer field "requests_today"
   24.
   25.     # I need this method to keep track of daily connection requests
   26.     # E.g., if admin sets daily limit to 20, user can send 20
   requests
   27.
   28.     # also, I don't know how to clear the "requests_today" on each
   24-hour period
   29.     # your help is greatly appreciated !
   30.
   31.     # please keep in mind that I am working on the insoshi project
   32.     # so, while the other code may appear expert, I am actually a
   noob.
   33.     # thanks again
   34.
   35.
   36.
   37.   end
   38.
   39.   def create
   40.     @contact = Person.find(params[:person_id])
   41.
   42.     respond_to do |format|
   43.       if Connection.request(current_person, @contact) && can_request?
   44.         flash[:notice] = 'Connection request sent!'
   45.         format.html { redirect_to(home_url) }
   46.       else
   47.         # This should only happen when people do something funky
   48.         # like friending themselves.
   49.         flash[:notice] = "Invalid connection"
   50.         format.html { redirect_to(home_url) }
   51.       end
   52.     end
   53.   end

--~--~---------~--~----~------------~-------~--~----~
Insoshi developer site: http://dogfood.insoshi.com/
Insoshi documentation: http://docs.insoshi.com/

You received this message because you are subscribed to the Google
Groups "Insoshi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/insoshi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to