I am Rails newbie.. so I could be totally wrong. I was working in simple rails application that stores some objects in Session. When I started working in another application.. I am getting this session can''t be loaded. Is this a problem wth WEBrick ? Is there a solution to this? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On Jun 10, 2005, at 12:21 PM, Siva Jagadeesan wrote:> I am Rails newbie.. so I could be totally wrong. > > I was working in simple rails application that stores some objects in > Session. When I started working in another application.. I am getting > this session can''t be loaded. Is this a problem wth WEBrick ? > > Is there a solution to this? > >You''ll want to set your session key name to be unique to your application. In config/environment.rb you can put: ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = "MyApplication" If you don''t do this, applications on the same host (even if running on a different port) can tromp on each others sessions, and you don''t want this. It''s a cookie thing. -Scott _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Just submitted a ticket to have this built into the generator. - B On Jun 10, 2005, at 1:37 PM, Scott Barron wrote:> > On Jun 10, 2005, at 12:21 PM, Siva Jagadeesan wrote: > >> I am Rails newbie.. so I could be totally wrong. >> >> I was working in simple rails application that stores some objects >> in Session. When I started working in another application.. I am >> getting this session can''t be loaded. Is this a problem wth WEBrick ? >> >> Is there a solution to this? >> >> > > You''ll want to set your session key name to be unique to your > application. > > In config/environment.rb you can put: > > ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = > "MyApplication" > > If you don''t do this, applications on the same host (even if running > on a different port) can tromp on each others sessions, and you don''t > want this. It''s a cookie thing. > > -Scott > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Hi, I''m following this guide: http://wiki.rubyonrails.com/rails/show/HowToUseValidationsWithoutExtendingActiveRecord Everything seems to be working except for the error handling, if I submit a form that fails validation, error_messages_for shows duplicate entries - so if I post the same invalid form n times, I get n copies of the same error text.. My code can be seen here: http://www.rafb.net/paste/results/TxWDkp28.html Example of output of error_messages_for: 3 errors prohibited this feedback from being saved There were problems with the following fields: * comment can''t be empty * comment can''t be empty * comment can''t be empty I''ve tried calling error_messages_for, and checking errors.count at various stages prior to the valid? call.. everything reports a size of 0 before that call.. Failing that, is there a nice way to perform validation on forms not linked to a database table? Thanks Paul
Trevor Squires
2005-Jun-11 02:48 UTC
Re: Wiki: HowToUseValidationsWithoutExtendingActiveRecord
Hi Paul, I''m not sure how many people are using the info in that guide (I put it up on the wiki - tested to the extent of "it works for me") What happens if you stop and restart webrick (you *are* using webrick right?) ? After looking at your problem I got strange behavior that indicates webrick is not reloading my ValidatingBase derived classes when they get changed. Let me know if restarting webrick (or fcgi in dev mode if that''s what you''re doing) fixes it for you... Trevor On 10-Jun-05, at 6:07 PM, Paul King wrote:> > Hi, > > I''m following this guide: > http://wiki.rubyonrails.com/rails/show/ > HowToUseValidationsWithoutExtendingActiveRecord > > Everything seems to be working except for the error handling, if I > submit a form that fails validation, error_messages_for shows > duplicate entries - so if I post the same invalid form n times, I get > n copies of the same error text.. > > My code can be seen here: > http://www.rafb.net/paste/results/TxWDkp28.html > > Example of output of error_messages_for: > > 3 errors prohibited this feedback from being saved > > There were problems with the following fields: > > * comment can''t be empty > * comment can''t be empty > * comment can''t be empty > > I''ve tried calling error_messages_for, and checking errors.count at > various stages prior to the valid? call.. everything reports a size of > 0 before that call.. > > Failing that, is there a nice way to perform validation on forms not > linked to a database table? > > Thanks > Paul > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Trevor Squires
2005-Jun-11 03:16 UTC
Re: Wiki: HowToUseValidationsWithoutExtendingActiveRecord
Paul, I''ve just had it confirmed on IRC that classes in the models directory which don''t extend ActiveRecord::Base are not automatically reloaded by webrick - you have to manually restart the server to see your changes for those files. I''ve updated the wiki entry to warn about this. I hope that was the source of your problem, Trevor On 10-Jun-05, at 6:07 PM, Paul King wrote:> > Hi, > > I''m following this guide: > http://wiki.rubyonrails.com/rails/show/ > HowToUseValidationsWithoutExtendingActiveRecord > > Everything seems to be working except for the error handling, if I > submit a form that fails validation, error_messages_for shows > duplicate entries - so if I post the same invalid form n times, I get > n copies of the same error text.. > > My code can be seen here: > http://www.rafb.net/paste/results/TxWDkp28.html > > Example of output of error_messages_for: > > 3 errors prohibited this feedback from being saved > > There were problems with the following fields: > > * comment can''t be empty > * comment can''t be empty > * comment can''t be empty > > I''ve tried calling error_messages_for, and checking errors.count at > various stages prior to the valid? call.. everything reports a size of > 0 before that call.. > > Failing that, is there a nice way to perform validation on forms not > linked to a database table? > > Thanks > Paul > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Nathaniel Talbott
2005-Jun-11 03:38 UTC
Re: Wiki: HowToUseValidationsWithoutExtendingActiveRecord
On 6/10/05, Trevor Squires <trevor-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> I''ve just had it confirmed on IRC that classes in the models directory > which don''t extend ActiveRecord::Base are not automatically reloaded by > webrick - you have to manually restart the server to see your changes > for those files. > > I''ve updated the wiki entry to warn about this.I struggled with this myself, and managed to find the magic line to get automatic updating in development mode. All you need to do is add your base class to the arguments to Dependencies.remove_subclasses_for in public/dispatch.rb, and it''ll then work like a champ in development. I''ve updated the wiki to capture this step, and removed the warning. Hope that helps, -- Nathaniel <:((><
Hi Trevor / Nathaniel Thanks for your replies! Trevor you were right that the changes wouldn''t appear until I restarted webrick - but then they just started to build up again. Adding the line that Nathaniel recommends does solve the problem for webrick (hurray!) - I''ve tried something similar for lighttpd/fcgi in production mode but I''m unable to get it to follow suit (dispatch.fcgi is pretty different from dispatch.rb/cgi given its nature, I guess) Any ideas? Thanks again, Paul Nathaniel Talbott wrote:>On 6/10/05, Trevor Squires <trevor-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: > > > >>I''ve just had it confirmed on IRC that classes in the models directory >>which don''t extend ActiveRecord::Base are not automatically reloaded by >>webrick - you have to manually restart the server to see your changes >>for those files. >> >>I''ve updated the wiki entry to warn about this. >> >> > >I struggled with this myself, and managed to find the magic line to >get automatic updating in development mode. All you need to do is add >your base class to the arguments to Dependencies.remove_subclasses_for >in public/dispatch.rb, and it''ll then work like a champ in >development. > >I''ve updated the wiki to capture this step, and removed the warning. > >Hope that helps, > > > >
Trevor Squires
2005-Jun-11 20:02 UTC
Re: Wiki: HowToUseValidationsWithoutExtendingActiveRecord
On 11-Jun-05, at 3:31 AM, Paul King wrote:> > Hi Trevor / Nathaniel > > Thanks for your replies! > Trevor you were right that the changes wouldn''t appear until I > restarted webrick - but then they just started to build up again. > Adding the line that Nathaniel recommends does solve the problem for > webrick (hurray!) - I''ve tried something similar for lighttpd/fcgi in > production mode but I''m unable to get it to follow suit (dispatch.fcgi > is pretty different from dispatch.rb/cgi given its nature, I guess)Hi again Paul, this is odd, and not the behavior I get. I assumed that when you said it was accumulating errors that what was really happening was that webrick wasn''t detecting changes (sorry). Seeing as I don''t accumulate errors I have to assume you''re doing something that I''m not... I can''t devote any significant time to this today but I''ll see if I can look at it late tonight. Perhaps it''s better to take this discussion offline while we to-and-fro to figure it out. I''ll be on IRC (as protocool) off and on today if you want to bounce any ideas around. Regards, Trevor
Nathaniel Talbott
2005-Jun-13 11:44 UTC
Wiki: HowToUseValidationsWithoutExtendingActiveRecord
On 6/11/05, Trevor Squires <trevor-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> I don''t have that line in my public/dispatch.rb file and I can''t see it > in edge rails or an older (0.9) versions of rails... > > What version are you using?0.12.1... I forgot that I copied Dispatcher#reset_application from dispatcher.rb in to my public/dispatch.rb so I could modify it locally. I''ll clarify that on the wiki. -- Nathaniel <:((><
Scott Barron wrote:> > You''ll want to set your session key name to be unique to your application. > > In config/environment.rb you can put: > > ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS[:session_key] = > "MyApplication" > > If you don''t do this, applications on the same host (even if running on > a different port) can tromp on each others sessions, and you don''t want > this. It''s a cookie thing.Nasty. What happens if one changes this for applications that are already deployed? James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys
On 6/14/05, James Britt <james.britt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Nasty. What happens if one changes this for applications that are > already deployed?Everyone will lose their sessions, so be very careful. However if you''re just using session to store a few ids, it won''t be that big a deal.> James > -- > http://www.ruby-doc.org - The Ruby Documentation Site > http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML > http://www.rubystuff.com - The Ruby Store for Ruby Stuff > http://www.jamesbritt.com - Playing with Better Toys > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
Michael Koziarski wrote:> On 6/14/05, James Britt <james.britt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>Nasty. What happens if one changes this for applications that are >>already deployed? > > > Everyone will lose their sessions, so be very careful. However if > you''re just using session to store a few ids, it won''t be that big a > deal.OK, that''s no problem. Thanks, James -- http://www.ruby-doc.org - The Ruby Documentation Site http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys