NoMethodError in Static_pages#home
I'm getting a no method error in my Static_pages#home:
undefined method `exists?' for Registry
The little code I'm using it in is: <% if user_signed_in? && current_user.registry.exists? %> <%= link_to "Show My Registry", current_user.registry %> <% else %> <%= link_to "Create a new registry", new_registry_path %> <% end %>
Should I add something to the controller for home?
Thanks in advance.
The exists? method is a class method. You have to either do:
Registry.exists? # Is there any registery?
or specify the id for the Registry:
Here is some reference:
In the end this worked:
<% if user_signed_in? && Registry.exists?(current_user.registry) %>