hello ther, If I view my profile within my application, I can see 2 links. 1 = get in touch and 2 = friend request. Obviously if this is my own profile, I dont want to contact myself, nor add myself as a friend. So - I had this that I found in the book: <% if logged_in? and @user != @logged_in_user %> When added to the page which shows my profile, it looks like this: <% if logged_in? and @user != @logged_in_user %> <div class="users_profile"> <h2> <span class="header">Actions</span> <br clear="all" /> </h2> <ul> <li> <%= link_to "Get in touch", :controller => "email", :action => "correspond", :id => @user.username %> </li> <li> <%= friendship_status(@logged_in_user, @user) %> <% unless Friendship.exists?(@logged_in_user, @user) %> <%= link_to "Buddy up with #{@user.username}", { :controller => "friendship", :action => "create", :id => @user.username }, :confirm => "Send buddy request to #{@user.username}?" %> <% end %> <% end %> </ul> </div> However - even with this in place, I still get the links to contact myself, and add myself as a friend. I then thought - perhaps I could add the hide_edit_links to the links i wish to hide. So I added; <% unless hide_edit_links? %> before the 2 links. Unfortunately this only seems to hide these for all users. So - if i view someone e;ses profile, I cannot email them or add as a friend. Any suggestions how I hide these links, without hiding all links? Thanks for reading - hope someone can help. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, Nov 29, 2009 at 2:49 PM, RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> If I view my profile within my application, I can see 2 links. 1 = get > in touch and 2 = friend request. > > Obviously if this is my own profile, I dont want to contact myself, > nor add myself as a friend.> When added to the page which shows my profile, it looks like this: > > <% if logged_in? and @user != @logged_in_user %>> However - even with this in place, I still get the links to contact > myself, and add myself as a friend.So what are the values of those three variables at that point? You don''t show how any of them are being set... -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
lancecarlson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2009-Nov-30 08:51 UTC
Re: hiding specific links
A ghetto but simple and quick way to figure out what is going on, is to do a logger.info in your controller action of these: logged_in? @user @logged_in_user I think you will quickly identify your problem then On Nov 29, 10:00 pm, Hassan Schroeder <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Nov 29, 2009 at 2:49 PM, RubyonRails_newbie > > <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > If I view my profile within my application, I can see 2 links. 1 = get > > in touch and 2 = friend request. > > > Obviously if this is my own profile, I dont want to contact myself, > > nor add myself as a friend. > > When added to the page which shows my profile, it looks like this: > > > <% if logged_in? and @user != @logged_in_user %> > > However - even with this in place, I still get the links to contact > > myself, and add myself as a friend. > > So what are the values of those three variables at that point? You > don''t show how any of them are being set... > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassan-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi everyone, I have an account page in which users can update their status. Posts are limited to the most recent update, so it all looks nice and current. The user can also delete a status update one at a time). I''m looking to try and add a feature that hides the "Delete Posts" link, if no posts currently exist. And then once a post(s) exist, the delete link is then displayed again. I had this, but it doesn''t seem to work: <% if Post.exists? %> No posts yet? Add one now! (This will be shown to anyone who views your profile!) <% else %> <%= image_tag ("delete.png") %> <%= link_to "Delete post?", { :controller => "posts", :action => "delete", :id => @posts }, :confirm => "Really delete this post? You cannot undo this!" %> | <% end %> Any ideas how to do this? I''ve tried a few combinations, but can''t get to the solution. Will keep trying!! :-) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
** Resolved... ** If anyone else comes across a similar issue, I did this to hide the delete link if no posts exist: <% if Post.exists?(@posts) %> <%= image_tag ("delete.png") %> <%= link_to "Delete post", { :controller => "posts", :action => "delete", :id => @posts }, :confirm => "Really delete this post? You cannot undo this!" %> <% end %> On 6 Dec, 21:13, RubyonRails_newbie <craigwest...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Hi everyone, > > I have an account page in which users can update their status. Posts > are limited to the most recent update, so it all looks nice and > current. The user can also delete a status update one at a time). > > I''m looking to try and add a feature that hides the "Delete Posts" > link, if no posts currently exist. And then once a post(s) exist, the > delete link is then displayed again. > > I had this, but it doesn''t seem to work: > > <% if Post.exists? %> > > No posts yet? Add one now! (This will be shown to anyone who views > your profile!) > > <% else %> > > <%= image_tag ("delete.png") %> > > <%= link_to "Delete post?", > { :controller => "posts", :action => "delete", > :id => @posts }, > :confirm => "Really delete this post? You cannot undo this!" %> > | > > <% end %> > > Any ideas how to do this? I''ve tried a few combinations, but can''t get > to the solution. Will keep trying!! :-)-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
2009/12/6 RubyonRails_newbie <craigwesty79-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>:> ** Resolved... ** > > If anyone else comes across a similar issue, I did this to hide the > delete link if no posts exist: > > <% if Post.exists?(@posts) %> > > > <%= image_tag ("delete.png") %> > > <%= link_to "Delete post", > { :controller => "posts", :action => "delete", > :id => @posts }, > :confirm => "Really delete this post? You cannot undo this!" %> >Could you not just test @posts directly, presumably it will be nil or empty or something, or am I missing something? I am a bit confused as I would expect a variable called @posts to be an array of Post objects but since you are using :id => posts that suggests it is just one. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.