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.

Answers


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:

Registry.exist?(current_user.registry_id)

Here is some reference:

http://apidock.com/rails/ActiveRecord/Base/exists%3F/class

Good luck!


In the end this worked:

<% if user_signed_in? && Registry.exists?(current_user.registry) %>

Need Your Help

Silverlight ViewBase in separate assembly - possible?

msbuild silverlight-3.0

I have all my views in a project inheriting from a ViewBase class that inherits from UserControl. In my XAML I reference it thus:

How to create and apply CSS to javascript Alert

javascript css alert

Please tell me, how to apply CSS on javascript Alert.