Hello, I''m trying to use the following Struct in my web app: UserInfo = Struct.new( "UserInfo", :first_name, :last_name, :email, :domain_name ) I placed this in the environment.rb, thinking that it should be initialized only once. But when I try to access it from within my controller, I get: undefined method `UserInfo'' for #<UserController:0x243ad5c>. so my questions are: 1) is environment.rb the correct place to define a struct? If not, what''s the alternative. Also, what''s the best place to define classes that are neither controllers nor models? 2) if struct definition in environment.rb is the proper place to define a struct, how can I get my controller to know what a UserInfo is? Thanks in advance. Cagan -- Posted via http://www.ruby-forum.com/.
Hello, I''m trying to use the following Struct in my web app: UserInfo = Struct.new( "UserInfo", :first_name, :last_name, :email, :domain_name ) I placed this in the environment.rb, thinking that it should be initialized only once. But when I try to access it from within my controller, I get: undefined method `UserInfo'' for #<UserController:0x243ad5c>. so my questions are: 1) is environment.rb the correct place to define a struct? If not, what''s the alternative. Also, what''s the best place to define classes that are neither controllers nor models? 2) if environment.rb is the proper place to define a struct, how can I get my controller to know what a UserInfo is? Thanks in advance. Cagan -- Posted via http://www.ruby-forum.com/.
On 6/14/06, cagan senturk <cs327@teknolabs.com> wrote:> 1) is environment.rb the correct place to define a struct? If not, > what''s the alternative. Also, what''s the best place to define classes > that are neither controllers nor models?I''m not fully awake yet, but I think you may want to place it in your application.rb instead, or in a separate module/helper and make sure you include it. HTH Mathias.
cagan senturk wrote:> Hello, > > I''m trying to use the following Struct in my web app: > UserInfo = Struct.new( "UserInfo", :first_name, :last_name, :email, > :domain_name ) > > I placed this in the environment.rb, thinking that it should be > initialized only once. > But when I try to access it from within my controller, I get: > > undefined method `UserInfo'' for #<UserController:0x243ad5c>. > > so my questions are: > > 1) is environment.rb the correct place to define a struct? If not, > what''s the alternative. Also, what''s the best place to define classes > that are neither controllers nor models? > 2) if environment.rb is the proper place to define a struct, how can I > get my controller to know what a UserInfo is? > > Thanks in advance. > CaganDoesn''t your database serve as the type definition? Ruby usually doesn''t usually require structs like this. -- Posted via http://www.ruby-forum.com/.