So I''m cleaning up my views at the moment, and thought it''d be
nice to
create a couple of helpers, one that shows links if the user is logged
in, and one that shows another set of links if they''re not logged in.
Anyways, this is the code:
def logged_in_links
if logged_in?
link_to ''New Highlight'', new_highlight_path
link_to ''Logout?'', logout_path
link_to ''Profile »'', @current_user.login
end
end
I''m sure I''m making a rudimentary mistake (take into account I
am a
beginner), but whenever I execute the helper method only the last link
shows up, and if I remove the last link than it''s the new last link
that
displays etc.
What am I doing wrong? :-)
--
Posted via http://www.ruby-forum.com/.
--
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.
Hello, only results of the last statement executed are returned. You have to
do something like
def logged_in_links
html = ''''
if logged_in?
html += link_to ''New Highlight'', new_highlight_path
html += link_to ''Logout?'', logout_path
html += link_to ''Profile »'', @current_user.login
end
html
end
2010/6/3 David Turnbull <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> So I''m cleaning up my views at the moment, and thought
it''d be nice to
> create a couple of helpers, one that shows links if the user is logged
> in, and one that shows another set of links if they''re not logged
in.
>
> Anyways, this is the code:
>
> def logged_in_links
> if logged_in?
> link_to ''New Highlight'', new_highlight_path
> link_to ''Logout?'', logout_path
> link_to ''Profile »'', @current_user.login
> end
> end
>
> I''m sure I''m making a rudimentary mistake (take into
account I am a
> beginner), but whenever I execute the helper method only the last link
> shows up, and if I remove the last link than it''s the new last
link that
> displays etc.
>
> What am I doing wrong? :-)
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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.
Ah, okay. Thanks for the hlep. Gintautas Šimkus wrote:> Hello, only results of the last statement executed are returned. You > have to > do something like > > def logged_in_links > html = '''' > if logged_in? > html += link_to ''New Highlight'', new_highlight_path > html += link_to ''Logout?'', logout_path > html += link_to ''Profile »'', @current_user.login > end > html > end > > 2010/6/3 David Turnbull <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>-- Posted via http://www.ruby-forum.com/. -- 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.