Hi, Another silly question: where can I find docs about session management? I came from Apple''s WebObjects which is a well documented (and also well designed) web application framework and I really miss sessions in Ruby On Rails. I need the points of session creation and disposal. And a plus question: I see the layout of a tipical rails app. But where''s the place of other custom business logic classes? How to place them? Thanks again, Gábor To be is to do. - Socrates To do is to be. - Sartre Do be do be do. - Sinatra
> Another silly question: where can I find docs about session > management? I came from Apple''s WebObjects which is a well documented > (and also well designed) web application framework and I really miss > sessions in Ruby On Rails. I need the points of session creation and > disposal.Setting a session value: @session[:greeting] = "Hello world!" Reading a session value: @session[:greeting] # => "Hello world!" Deleting a single session value: @session.delete :greeting Clearing an entire session: reset_session See more under "Sessions" in http://rails.rubyonrails.com/classes/ActionController/Base.html> And a plus question: I see the layout of a tipical rails app. But > where''s the place of other custom business logic classes? How to place > them?If they''re entity/value object classes, they go into app/models. If they''re libraries, they go into lib/. Both places are part of the load path. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.loudthinking.com/ -- Broadcasting Brain
On 2005.03.20., at 13:01, David Heinemeier Hansson wrote:> See more under "Sessions" in > http://rails.rubyonrails.com/classes/ActionController/Base.html >Thanks! Let me ask more questions :) 1. I want to implement session.initialize() and session.terminate() methods. What to override / subclass? 2. How can sessions intercommunicate? Consider a chat server where a message came from a session should be broadcasted to other ones. Is there way to implement this "feature"? Does Rails have such a feature? Gábor To be is to do. - Socrates To do is to be. - Sartre Do be do be do. - Sinatra
> Let me ask more questions :) > 1. I want to implement session.initialize() and session.terminate() > methods. What to override / subclass?before_filter { session_initialize if @session.empty? } def session_initialize [...] end Sessions never terminate.> 2. How can sessions intercommunicate? Consider a chat server where a > message came from a session should be broadcasted to other ones. Is > there way to implement this "feature"? Does Rails have such a feature?Sessions are made to not intercommunicate. Thats the entire reason for them; They are specific to the user. Its still easy to implement something like this. If you are using webrick you can just use a global variable (array) in which you can push new chat lines. If you are using fastcgi where you could have many instances of the application depending on traffic you would do better to create a super simple chat server ( can be 4 lines of code using DRb ) and your webapps connect to this chat server to get their content and push new chatlines. If you want to make it really nice you could have them connect to an irc server instead of a DRb server, but either way you need a shared resource. -- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog