session - Rails app generating extra output -


im trying fool around rails application learn proper way of doing things, , i've gotten great start, theres thing bugging me. pretty cosmetic, bugs h*** out of me.

i've made session controller , session helper take care of logging in , out, , believe works fine (havent tested yet), yet when want use if !signed_in?, output in view (where im using haml), below code believe involved in generating output.

sessions_helper.rb:

def get_current_user   @current_user ||= false end  def signed_in?    !get_current_user.nil? end 

partial: _menu.html.haml (im still learning make ruby-isk)

%nav   #userbox     =if signed_in?       =link_to 'create user', :signup       |       =link_to 'log in', :signin     =if !signed_in?       =link_to "my profile", :root       |       =link_to 'log out', :signout   %ul     %li= link_to 'about', :about     %li= link_to 'concept', :concept     %li= link_to 'home', :root 

this ends generating following html:

<nav>    <div id='userbox'>      <a href="/signup">create user</a>      |     <a href="/signin">log in</a>    2    </div>    <ul>      <li><a href="/about">about</a></li>      <li><a href="/concept">concept</a></li>      <li><a href="/">home</a></li>    </ul>  </nav>  

the issue here number 2 generated. how remove that?

try use - instead of = in ruby code not render code:

%nav   #userbox     - if signed_in?       =link_to 'create user', :signup       |       =link_to 'log in', :signin     - if !signed_in?       =link_to "my profile", :root       |       =link_to 'log out', :signout   %ul     %li= link_to 'about', :about     %li= link_to 'concept', :concept     %li= link_to 'home', :root 

see here documentation run ruby code: http://haml-lang.com/docs/yardoc/file.haml_reference.html#running_ruby_


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -