Reputation: 15629
I have the following code in a partial view file _status.html.erb
.
<%=
if session[:user].nil?
"welcome new user"
link_to( 'Sign in', login_path)
else
render ( :text => "user name:")
h(session[:user].name)
end
%>
The only thing that I see though is the value of session[:user].name
. Any suggestions?
Upvotes: 0
Views: 745
Reputation: 17790
You really don't need to call render, unless it's located in another partial.
In erb:
<% if session[:user].nil? -%>
welcome new user
<%= link_to( 'Sign in', login_path) %>
<% else -%>
user name
<%= h(session[:user].name) %>
<% end -%>
Or in Haml:
- if session[:user].nil?
welcome new user
= link_to( 'Sign in', login_path)
- else
user name
= h(session[:user].name)
Upvotes: 3