Hi all, I've put new code into my app so that an administrator will have
extra privileges (administer users, edit pages). The error is:
'Couldn't find User without an ID'
So the app is looking for a logged in user when the homepage is
accessed.
Heres my code:
site/index view:
<% if is_logged_in? and logged_in_user.has_role?('Moderator') -%>
<%= link_to 'Administer Users', :controller => 'user', :action =>
'show' %>
<%= link_to ' | Edit pages', pages_path %>
<% end %>
application helper:
def is_logged_in?
@logged_in_user = User.find(session[:user_id])
@logged_in_user ? @logged_in_user : false
end
def logged_in_user
return @logged_in_user if is_logged_in?
How could I change the code to rectify this? Any help would be greatly
appreciated
Steve.
--
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---