Asbjorn,

Would you mind posting your final working code as comments to the recipe?
That may help others in the future.

Thanks,

Owen

On Thu, Jan 7, 2010 at 2:03 PM, kevinpfromnm <[email protected]> wrote:

> Just associations.  Friendship belongs_to two users, invitee and
> invitor.
>
>  has_many :friend_invites, :class_name => "Friendship", :foreign_key
> => :invitee_id, :dependent => :destroy
>  has_many :friend_invitors, :class_name => "Friendship", :foreign_key
> => :invitor_id, :dependent => :destroy
>
>
> On Jan 7, 4:54 am, atmorell <[email protected]> wrote:
> > Hello Kevin,
> >
> > Thank you so much for your example. This is so usefull. Could you
> > explain to me how you created the friends and friend_invites methods?
> > At the moment my user has no relation to the friendship module.
> >
> >  NoMethodError in UsersController#show
> >
> > undefined method `friends' for #<User:0x4356430>
> >
> > Best regards.
> > Asbjørn Morell
> >
> > On Jan 6, 9:28 pm, kevinpfromnm <[email protected]> wrote:
> >
> > > You have to tweak it more than just the putting in the invite-form...
> > > when I did it, I ended up making an invite button that was the form
> > > with the context (user) as a hidden id sent with.  This is what I had
> > > in my friendship taglib for a particular app:
> >
> > > <def tag="invite-button">
> > >   <% target = this %>
> > >   <do with="&Friendship.new">
> > >   <form controller="friendships" lifecycle="invite" unless="&target ==
> > > current_user or current_user.friends('all').include?(target)">
> > >     <input type="hidden" name="friendship[invitee_id]" value="#
> > > {target.id}" />
> > >     <submit label="Request as Friend" />
> > >   </form>
> > >   </do>
> > > </def>
> > > <def tag="card" for="Friendship" attrs="parent">
> > >   <% parent ||= @user %>
> > >   <card merge>
> > >     <body:>
> > >                         <view:invitee unless="&this.invitee == parent"
> />
> > >                         <view:invitor unless="&this.invitor == parent"
> />
> > >       <transition-buttons />
> > >     </body:>
> > >   </card>
> > > </def>
> > > <def tag="friend-requests">
> > >         <collection:friend_invites.pending>
> > >                 <empty-message:>No pending friend
> invites.</empty-message:>
> > >                 <card: parent="&current_user" />
> > >         </collection>
> > > </def>
> > > <def tag="requested-friends">
> > >         <collection:friend_invitors.pending>
> > >                 <empty-message:>No friend requests
> pending.</empty-message:>
> > >                 <card: parent="&current_user" />
> > >         </collection>
> > > </def>
> >
> > > On Jan 3, 11:05 am, atmorell <[email protected]> wrote:
> >
> > > > Hello,
> >
> > > > The lifecycle tutorial shows how to implement a friendship logic in
> > > > the model and controller. However it does not really cover how to
> glue
> > > > the gui/views together. When I go to /friendships/invite - hobo
> > > > presents me with a form with a drop down menu. How do I add a form to
> > > > the user show-page with just one button (Invite) I guess that the the
> > > > user viewed should be in a hidden field?
> >
> > > > I tried adding the form like this:
> >
> > > > <extend tag="show-page" for="User">
> > > >   <old-show-page merge>
> > > >     <append-content-body:>
> > > >       <invite-form for="Friendship" />
> > > >     </append-content-body:>
> > > >   </old-show-page>
> > > > </extend>
> >
> > > > Hobo ignores the invite-form hmmm I must be missing something.
> >
> > > > Best regards
> > > > Asbjørn Morell
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<hobousers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.
>
>
>
>


-- 
Thanks,

Owen

Owen Dall
Barquin International
410-991-0811
--
You received this message because you are subscribed to the Google Groups "Hobo Users" 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/hobousers?hl=en.

Reply via email to