Hello,
currently I''m writing on a PlugIn for my Project.
In this PlugIn I MUST include two Constants. But where do I include
them?
Here''s the Code of the PlugIn:
# Status
module ___Plugins
module Internal #:nodoc:
module Status #:nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def status
include ___Plugins::Internal::Status::InstanceMethods
extend ___Plugins::Internal::Status::SingletonMethods
attr_accessor :public_state
attr_accessor :commentable_state
validates_inclusion_of :public_state, :in =>
PUBLIC_STATE
validates_inclusion_of :commentable_state, :in =>
COMMENTABLE_STATE
end
PUBLIC_STATE = {
''closed'' =>
''Geschlossen'',
''password_safe'' => ''Password
geschützt'',
''friends_only'' => ''Nur für
Freunde offen'',
''opened'' =>
''Offen''
}
COMMENTABLE_STATE = {
''world'' =>
''Jeder'',
''internal'' => ''___.de
Nutzer'',
''friends'' => ''Nur
Freunde'',
''nobody'' =>
''Keiner''
}
end
# This module contains instance methods
module InstanceMethods
def can_see?(user)
return false if self.user.is_ignored?(user)
return true if self.public_state == "opened"
return true if self.public_state == "password_safe"
return true if self.public_state == "friends_only"
&&
self.user.is_friend?(user)
return false
end
def can_comment?(user)
return false if self.user.is_ignored?(user)
return true if self.commentable_state == "world"
return true if self.commentable_state == "internal"
&& (user
&& User.find_by_id(user.id))
return true if self.commentable_state == "friends"
&&
self.user.is_friend?(user)
end
end
# This module contains class methods
module SingletonMethods
end
end
end
end
Sorry but I have to mask the domain name with underscores.
The two constants are PUBLIC_STATE and COMMENTABLE_STATE.
When I run the Controller Action I get the following error message:
"uninitialized constant PUBLIC_STATE"
Source:
5: <pre><%= h album.description %></pre>
6: <p><a href="http://<%= current_user.login
%>.___.de/photoalbum/show/<%= album.permalink
%>">http://<%current_user.login
%>.___.de/photoalbum/show/<%= album.permalink
%></a></p>
7: <p>
8: Status: <%= PhotoAlbum::PUBLIC_STATE[album.public_state]
%><br />
9: Kommentieren:
<%PhotoAlbum::COMMENTABLE_STATE[album.commentable_state] %>
10: </p>
11: <p>
But why? I mixed the module ___::Internal::Status into my PhotoAlbum
model class.
Greets
Christoph
Sorry for my bad english, but I am German.
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---