Hi I am running Mac OX tiger with the installed ruby 1.8.2, and mysql5 (I checked that it was running in preference). I tried to run the various fixes recommended in agileweb. I am stuck on page 57, script/generate scaffold...> Could you paste in your database.yml file, from the > "config" folder inside your Rails app? If you have any > passwords entered there, you should change them to > nonsense before sending.development: adapter: mysql database: depot_development host: localhost username: root password: $564^%# test: adapter: mysql database: depot_test host: localhost username: root password: 0#@^463 production: adapter: mysql database: depot_production host: localhost username: prod password: wibble Is there a way to check that I have indeed all the pieces fixed that need to be fixed? the #46 fix, or how do I test this mysql gem? thank you for your help, anne
Anne G
2006-Jan-26 17:42 UTC
[Rails] iteration A4: new list.rhtml per page 67-68 gives a syntax error
I replaced the default list.rhtml with the copy/paste of the text of page 67-68 from the rails-code.tgz and added the text with copy/paste for page 69 scaffold.css. I get an error message which starts with compile error script/../config/../app/views/admin/list.rhtml:1: syntax error _erbout = ''''; _erbout.concat "<h1>Product Listing</h1>\r\r<table cellpadding=\"5\" cellspacing=\"0\">\r"; odd_or_even = 0 for product in @products odd_or_even = 1 - odd_or_even ; _erbout.concat "\r <tr valign=\"top\" class=\"ListLine"; _erbout.concat(( odd_or_even ).to_s); _erbout.concat "\">\r\r <td>\r <img width=\"60\" height=\"70\" src=\""; _erbout.concat(( product.image_url ).to_s); _erbout.concat "\"/>\r </td>\r\r <td width=\"60%\">\r <span class=\"ListTitle\">"; _erbout.concat(( h(product.title) ).to_s); _erbout.concat "</span><br />\r "; _erbout.concat(( h(truncate(product.description, 80)) ).to_s); _erbout.concat "\r </td>\r\r <td align=\"right\">\r "; _erbout.concat(( product.date_available.strftime("%y-%m-%d") ).to_s); _erbout.concat "<br/>\r <strong>$"; _erbout.concat(( sprintf("%0.2f", product.price) ).to_s); _erbout.concat "</strong>\r </td>\r\r <td class=\"ListActions\">\r "; _erbout.concat(( link_to ''Show'', :action => ''show'', :id => pro As far as I can tell, the downloaded code from depot4 folder is the same as in the book. How do I debug a syntax error like this? anne
Ben Reubenstien
2006-Jan-26 18:53 UTC
[Rails] iteration A4: new list.rhtml per page 67-68 gives a syntax error
Without seeing the rhtml I can''t offer a definitive reason. When I get syntax errors like this I usually back out whatever I have added to my RHTML, and add it back incrementally to spot the error. ~ Ben On 1/26/06, Anne G <anne@wjh.harvard.edu> wrote:> > I replaced the default list.rhtml with the copy/paste of the > text of page 67-68 from the rails-code.tgz and added the > text with copy/paste for page 69 scaffold.css. > > I get an error message which starts with > compile error > script/../config/../app/views/admin/list.rhtml:1: syntax > error > _erbout = ''''; _erbout.concat "<h1>Product > Listing</h1>\r\r<table cellpadding=\"5\" > cellspacing=\"0\">\r"; > odd_or_even = 0 > for product in @products > odd_or_even = 1 - odd_or_even > ; _erbout.concat "\r <tr valign=\"top\" class=\"ListLine"; > _erbout.concat(( odd_or_even ).to_s); _erbout.concat > "\">\r\r <td>\r <img width=\"60\" height=\"70\" > src=\""; _erbout.concat(( product.image_url ).to_s); > _erbout.concat "\"/>\r </td>\r\r <td width=\"60%\">\r > <span class=\"ListTitle\">"; _erbout.concat(( > h(product.title) ).to_s); _erbout.concat "</span><br />\r > "; _erbout.concat(( h(truncate(product.description, 80)) > ).to_s); _erbout.concat "\r </td>\r\r <td > align=\"right\">\r "; _erbout.concat(( > product.date_available.strftime("%y-%m-%d") ).to_s); > _erbout.concat "<br/>\r <strong>$"; _erbout.concat(( > sprintf("%0.2f", product.price) ).to_s); _erbout.concat > "</strong>\r </td>\r\r <td class=\"ListActions\">\r > "; _erbout.concat(( link_to ''Show'', :action => ''show'', :id > => pro > > As far as I can tell, the downloaded code from depot4 folder > is the same as in the book. How do I debug a syntax error > like this? > > anne > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060126/dcf572f6/attachment.html
Marc Croom
2006-Jan-26 18:56 UTC
[Rails] iteration A4: new list.rhtml per page 67-68 gives a syntax error
Check that you haven''t put a <%= when you meant <% That''s sometimes been the cause of similar errors for me. Ben Reubenstien wrote:> Without seeing the rhtml I can''t offer a definitive reason. When I > get syntax errors like this I usually back out whatever I have added > to my RHTML, and add it back incrementally to spot the error. > > ~ Ben > > On 1/26/06, *Anne G* <anne@wjh.harvard.edu > <mailto:anne@wjh.harvard.edu>> wrote: > > I replaced the default list.rhtml with the copy/paste of the > text of page 67-68 from the rails-code.tgz and added the > text with copy/paste for page 69 scaffold.css. > > I get an error message which starts with > compile error > script/../config/../app/views/admin/list.rhtml:1: syntax > error > _erbout = ''''; _erbout.concat "<h1>Product > Listing</h1>\r\r<table cellpadding=\"5\" > cellspacing=\"0\">\r"; > odd_or_even = 0 > for product in @products > odd_or_even = 1 - odd_or_even > ; _erbout.concat "\r <tr valign=\"top\" class=\"ListLine"; > _erbout.concat(( odd_or_even ).to_s); _erbout.concat > "\">\r\r <td>\r <img width=\"60\" height=\"70\" > src=\""; _erbout.concat(( product.image_url ).to_s); > _erbout.concat "\"/>\r </td>\r\r <td width=\"60%\">\r > <span class=\"ListTitle\">"; _erbout.concat(( > h(product.title) ).to_s); _erbout.concat "</span><br />\r > "; _erbout.concat(( h(truncate(product.description, 80)) > ).to_s); _erbout.concat "\r </td>\r\r <td > align=\"right\">\r "; _erbout.concat(( > product.date_available.strftime("%y-%m-%d") ).to_s); > _erbout.concat "<br/>\r <strong>$"; _erbout.concat(( > sprintf("%0.2f", product.price) ).to_s); _erbout.concat > "</strong>\r </td>\r\r <td class=\"ListActions\">\r > "; _erbout.concat(( link_to ''Show'', :action => ''show'', :id > => pro > > As far as I can tell, the downloaded code from depot4 folder > is the same as in the book. How do I debug a syntax error > like this? > > anne > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org <mailto:Rails@lists.rubyonrails.org> > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Ben Reubenstein > http://www.benr75.com > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >------------------------------------------------------------------------ > >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.1.375 / Virus Database: 267.14.23/240 - Release Date: 25/01/2006 > > >
Wilson Bilkovich
2006-Jan-26 20:51 UTC
[Rails] iteration A4: new list.rhtml per page 67-68 gives a syntax error
On 1/26/06, Anne G <anne@wjh.harvard.edu> wrote:> I replaced the default list.rhtml with the copy/paste of the > text of page 67-68 from the rails-code.tgz and added the > text with copy/paste for page 69 scaffold.css. > > I get an error message which starts with > compile error > script/../config/../app/views/admin/list.rhtml:1: syntax > error > _erbout = ''''; _erbout.concat "<h1>Product > Listing</h1>\r\r<table cellpadding=\"5\" > cellspacing=\"0\">\r"; > odd_or_even = 0 > for product in @products > odd_or_even = 1 - odd_or_even > ; _erbout.concat "\r <tr valign=\"top\" class=\"ListLine"; > _erbout.concat(( odd_or_even ).to_s); _erbout.concat > "\">\r\r <td>\r <img width=\"60\" height=\"70\" > src=\""; _erbout.concat(( product.image_url ).to_s); > _erbout.concat "\"/>\r </td>\r\r <td width=\"60%\">\r > <span class=\"ListTitle\">"; _erbout.concat(( > h(product.title) ).to_s); _erbout.concat "</span><br />\r > "; _erbout.concat(( h(truncate(product.description, 80)) > ).to_s); _erbout.concat "\r </td>\r\r <td > align=\"right\">\r "; _erbout.concat(( > product.date_available.strftime("%y-%m-%d") ).to_s); > _erbout.concat "<br/>\r <strong>$"; _erbout.concat(( > sprintf("%0.2f", product.price) ).to_s); _erbout.concat > "</strong>\r </td>\r\r <td class=\"ListActions\">\r > "; _erbout.concat(( link_to ''Show'', :action => ''show'', :id > => pro > > As far as I can tell, the downloaded code from depot4 folder > is the same as in the book. How do I debug a syntax error > like this? >Can you paste in the code? Usually the "line 1" error means that you''ve got a <% or <%= opening tag that isn''t closed. Unfortunately, these "totally couldn''t handle it" error messages are the hardest to track down. Luckily, they usually end up being something really simple. You can find them with an editor that has serious syntax highlighting (like vim or TextMate). If you''re using something else, you can chop it up into pieces and run it a bit at a time. Add one block of code at a time, until you find the error.
Anne G
2006-Jan-27 00:55 UTC
[Rails] Re: iteration A4: new list.rhtml per page 67-68 gives a syntax error
this is the text copy pasted from the list.rhtml file from the book''s rails-code.tgz from folder depot4: list.rhtml should be as listed page 68. text wrangler does put some colors, I did not see any mismatch. I start geting an error as soon as I put the first lines with <% ... %> that seems to define some macro, don''t know why it would triger an error. <h1>Product Listing</h1> <table cellpadding="5" cellspacing="0"> <% odd_or_even = 0 for product in @products odd_or_even = 1 - odd_or_even %> <tr valign="top" class="ListLine<%= odd_or_even %>"> <td> <img width="60" height="70" src="<%= product.image_url %>"/> </td> <td width="60%"> <span class="ListTitle"><%= h(product.title) %></span><br /> <%= h(truncate(product.description, 80)) %> </td> <td align="right"> <%= product.date_available.strftime("%y-%m-%d") %><br/> <strong>$<%= sprintf("%0.2f", product.price) %></strong> </td> <td class="ListActions"> <%= link_to ''Show'', :action => ''show'', :id => product %><br/> <%= link_to ''Edit'', :action => ''edit'', :id => product %><br/> <%= link_to ''Destroy'', { :action => ''destroy'', :id => product }, :confirm => "Are you sure?" %> </td> </tr> <% end %> </table> <%= if @product_pages.current.previous link_to("Previous page", { :page => @product_pages.current.previous }) end %> <%= if @product_pages.current.next link_to("Next page", { :page => @product_pages.current.next }) end %> <br /> <%= link_to ''New product'', :action => ''new'' %>
Anne G
2006-Jan-27 01:40 UTC
[Rails] Re: iteration A4: new list.rhtml per page 67-68 gives a syntax error
Of course, right after I posted this info, I realized that there are two languages intermixed, the % language and the table language. And the first few lines start a for loop which is closed just before table is closed. Once I understood that, I was able to modify the list file little by little. It was cool to watch the changes happen. The book does not bother explaining anything, so at least with this method, you can guess what is going on, and look it up if it is of interest. I added the lines little by little, taking away lines also until the list file was the same as far as I could tell as the book''s file I was copying from, and no syntax error. --- the pictures did not load, oh well ~/Desktop/image.jpg --- I recopied the original text from the code download into the list file, and the syntax error came back. I will try again tomorrow. Thank you for your advice anne On Thu, 26 Jan 2006, Anne G wrote:> this is the text copy pasted from the list.rhtml file from > the book''s rails-code.tgz from folder depot4: list.rhtml > should be as listed page 68. >
Ben Reubenstien
2006-Jan-27 02:05 UTC
[Rails] Re: iteration A4: new list.rhtml per page 67-68 gives a syntax error
Hi Anne ~ Images need to be in the rails_root/public/images folder. It looks like you were trying to refer to your desktop. ~ Ben On 1/26/06, Anne G <anne@wjh.harvard.edu> wrote:> > Of course, right after I posted this info, I realized that > there are two languages intermixed, the % language and the > table language. And the first few lines start a for loop > which is closed just before table is closed. > > Once I understood that, I was able to modify the list file > little by little. It was cool to watch the changes happen. > The book does not bother explaining anything, so at least > with this method, you can guess what is going on, and look > it up if it is of interest. > > I added the lines little by little, taking away lines also > until the list file was the same as far as I could tell as > the book''s file I was copying from, and no syntax error. --- > the pictures did not load, oh well ~/Desktop/image.jpg --- > > I recopied the original text from the code download into > the list file, and the syntax error came back. > > I will try again tomorrow. Thank you for your advice > > anne > > On Thu, 26 Jan 2006, Anne G wrote: > > > this is the text copy pasted from the list.rhtml file from > > the book''s rails-code.tgz from folder depot4: list.rhtml > > should be as listed page 68. > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Reubenstein http://www.benr75.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060127/9d43c2b8/attachment.html
Anne G
2006-Jan-27 12:51 UTC
[Rails] Re: iteration A4: new list.rhtml per page 67-68 gives a syntax error
Very strange, this morning, the error was there. I went backward, taking code out chunk by chunk, but some error was there all the way. until I went to a blank page. I restarted with the download file, and now I don''t get any error. I can''t get the error even with the old files I believe gave the error. I tried editing the path of the image to image that are already in the images folder in public, image url /images/sk_auto_small.jpg /public/images/sk_auto_small.jpg ... nothing works.
Anne G
2006-Feb-02 16:52 UTC
[Rails] Loading pictures up front, key press response, timed display
HI Rails normally has an rhtml file on the server which is interpreted. If the rhtml has a load image command, it loads the image and presents it to the user. Is there a way to have Rails load all the images that are going to be used ahead of time? How would the code look different? -------------------------------------------- usually the user clicks on submit, which is really a link which is interpreted as a request by the controller. Is there a way to have Rails respond to a key press by storing the content of the key press and moving on to load the next image -------------------------------------------- As I understand it, the timing is mostly controlled by the user clicking on a link. Until then the server just sits there waiting for someone to request a link How can I use Ajax to control the timing of the presentation independently of a link request? thanks for your help anne
Anne G
2006-Feb-03 11:35 UTC
[Rails] Re: Loading pictures up front, key press response, timed display
Loading pictures up front: I found the following: "a plethora of solutions to the preloading image problem in JavaScript are available." http://www.ilovejackdaniels.com/css/preloading-images-with-css/ So that is a problem that people are thinking about, and there are ways to do it. I know that rails gives access to javascript through helper functions, so I am wondering if the ability to load pages all at once, or images all at once is available in rails. I hear that the Times has set it up so all the articles load up at once, so reading the paper is very fast, the articles are already there. ----------------------------------------------------------- for key presses, it might be more difficult, people seem more focused on the mouse, on mouse roll over... but if they give mouse interactivity, they give keyboard interactivity. --------------------------------------------------------- It seems to me that as web application are taking over behaviors of computer applications, they will need to do all the things a computer application can do, but we may be at the beginning of that era. Flash can do all I want to do, and it is loaded into and runs from a browser, but other tools like Rails may not be able to do such things yet? --------------------------------- I can always find my post on the web archive, but I don''t usually find them in the gmane rails archive. Yet they are mirrors of each other, no? thanks for your help
Anne G
2006-Feb-03 11:50 UTC
[Rails] Re: Loading pictures up front, key press response, timed display
feed://rss.gmane.org/gmane.comp.lang.ruby.rails Javascript to preload images for faster loading on later pages: <script language = JavaScript> if (document.images) { img1 = new Image(); img2 = new Image(); img1.src = "Image-Name-1.gif"; img2.src = "Image-Name-2.gif" } </script> Use of the image Image-Name-1.gif in subsequent pages will be loaded from chache. that should do the trick, load all the images at the start. But where do I put this javascript code in a rails project? I want to keep track of a person with session, and keep changing the picture as he proceeds with task...
Alex Young
2006-Feb-03 12:52 UTC
[Rails] Re: Loading pictures up front, key press response, timed display
Anne G wrote:> Loading pictures up front: > > I found the following: "a plethora of solutions to the > preloading image problem in JavaScript are available." > http://www.ilovejackdaniels.com/css/preloading-images-with-css/ > > So that is a problem that people are thinking about, and > there are ways to do it. I know that rails gives access to > javascript through helper functions, so I am wondering if > the ability to load pages all at once, or images all at once > is available in rails. >It''s available the same way it''s always been available - through judicious use of the right bits of HTML, Javascript and CSS. There aren''t many bits of Rails that specifically help browser pre-caching, or hidden div loading, but then there''s nothing to get in the way either...> I hear that the Times has set it up so all the articles load > up at once, so reading the paper is very fast, the articles > are already there.Not that I can see... Have you got a reference for that?> for key presses, it might be more difficult, people seem > more focused on the mouse, on mouse roll over... but if they > give mouse interactivity, they give keyboard interactivity. >Again, this is an HTML/Javascript thing, not Rails-specific. There might be some functionality in RJS templates to help out, but I can''t think of any off the top of my head. The accesskey attribute on form elements and links might be enough to give you the keypress functionality you want.> It seems to me that as web application are taking over > behaviors of computer applications, they will need to do all > the things a computer application can do, but we may be at > the beginning of that era. Flash can do all I want to do, > and it is loaded into and runs from a browser, but other > tools like Rails may not be able to do such things yet?There''s nothing really technologically new Rails brings to the table. It just ties everything together in a *really* tidy package. -- Alex
Alex Young
2006-Feb-03 12:55 UTC
[Rails] Re: Loading pictures up front, key press response, timed display
Anne G wrote:> <script language = JavaScript> > if (document.images) > { > img1 = new Image(); > img2 = new Image(); > img1.src = "Image-Name-1.gif"; > img2.src = "Image-Name-2.gif" > } > </script> > > Use of the image Image-Name-1.gif in subsequent pages will > be loaded from chache. > > that should do the trick, load all the images at the start. > But where do I put this javascript code in a rails project?Put that code in a template that will get loaded by the browser before the images are needed. Maybe in the head of application.rhtml, if it''s site-wide. -- Alex
anne g
2006-Feb-03 14:40 UTC
[Rails] Re: Loading pictures up front, key press response, timeddisplay
Thank you Alex for your help on this anne
On another programming list on which I''m active, I''ve (of course) mentioned my newfound interest in and focus on Rails. One of the long- time members, a pretty thoughtful guy, has emailed me privately and asked me if I could point him to any Rails apps that were handling huge amounts of traffic. I''ve had the usual conversations with him about what scalability really means, how few sites need to handle huge amounts of traffic, how Rails is just one component of the landscape, etc. Still, he wants to know if I can point him to any large-scale apps done in Rails. Is there an answer to this question? Or is it just one of those diversionary issues raised by people who are looking for some reason not to spend the time to evaluate a new technology deeply enough to draw their own conclusions? Thanks. (I did look at http://wiki.rubyonrails.org/rails/pages/RealWorldUsage but it''s impossible, of course, to tell which of those sites might be handling huge traffic volumes.)
Anne G
2006-Feb-04 20:34 UTC
[Rails] baby step1 how to access a database without using scafold?
I have a database exp in database.yml I have in the development section adapter: mysql database: exp username: root password: *** host: localhost That should allow for connection to the mysql database exp. I created a table stimulis, with 45 records of three columns id image_url name select * from stimulis shows them all in mysql 1. I generated a model file stimuli.rb class Stimuli < ActiveRecord::Base end this somehow establishes the connection with the table stimulis 2. I have a controller and an action hello class RunexpController < ApplicationController def hello @stimuliAr = Stimuli.find_all end end 3. I have a viewing html <body> <% @stimuliAr.each do |stim| %> <%= link_to stim.image_url, :action => "show", :id => stim.id %> <% end %> </body> I don''t have a show page yet, but that should not be a problem. when I try to view http://localhost:3000/runexp/hello in railrad I get an error message access denied for user ''root''@''localhost'' (using password no) which is strange because mysql is setup with a password, and I gave it in the config file, database.yml. I am probably missing a piece which is normally setup by scafold, is that so? what do I need to do? Am I on the right track? thanks Anne
A couple of the more well known applications would be 43 Things (http://www.43things.com/) with somewhere between 500K and 1MM requests per day and Basecamp (http://www.basecamphq.com/) with over 100,000 users. Others on the list can probably give you more specific examples for these two applications as well as others. Steven Smith On Feb 4, 2006, at 1:03 PM, Dan Shafer wrote:> On another programming list on which I''m active, I''ve (of course) > mentioned my newfound interest in and focus on Rails. One of the > long-time members, a pretty thoughtful guy, has emailed me > privately and asked me if I could point him to any Rails apps that > were handling huge amounts of traffic. I''ve had the usual > conversations with him about what scalability really means, how few > sites need to handle huge amounts of traffic, how Rails is just one > component of the landscape, etc. > > Still, he wants to know if I can point him to any large-scale apps > done in Rails. Is there an answer to this question? Or is it just > one of those diversionary issues raised by people who are looking > for some reason not to spend the time to evaluate a new technology > deeply enough to draw their own conclusions? > > Thanks. > > (I did look at http://wiki.rubyonrails.org/rails/pages/ > RealWorldUsage but it''s impossible, of course, to tell which of > those sites might be handling huge traffic volumes.) > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Anne G
2006-Feb-04 22:37 UTC
[Rails] Re: baby step1 how to access a database without using scafold?
1. I put a space in front of the password in database.yml, after "password:" 2. I rebooted the computer. It now seems to work. I am able to access all the information. How can I generalise to several tables. I assume I need one model per table? How do I write to a table? What do I need to understand about relational tables? thanks for a little help, this is good learning, but it is so slow finding this info, most tutorials I looked at use scaffold anne --------------------------------------------------- 1. I generated a model file stimuli.rb class Stimuli < ActiveRecord::Base end 2. I have a controller and an action hello class RunexpController < ApplicationController def hello @stimuliAr = Stimuli.find_all end end 3. I have a viewing html <body> <%= link_to @stimuliAr[0].image_url, :action => "show", :id => @stimuliAr[0].id %> </body>
Hey Dan ! I really dig this interview: http://www.oreillynet.com/pub/wlg/8274?wlg=yes Also, Ezra''s migration story is excellent: http://brainspl.at/articles/2005/11/03/from-start-to-launch-http-yakimaherald-com There are some others, but these two were enough to sell my employers on using RoR instead of the J2ee or PHP solution they were about to use :) =Dylan On 2/4/06, Steven Smith <ssmith@fiveruns.com> wrote:> > A couple of the more well known applications would be 43 Things > (http://www.43things.com/) with somewhere between 500K and 1MM > requests per day and Basecamp (http://www.basecamphq.com/) with over > 100,000 users. Others on the list can probably give you more > specific examples for these two applications as well as others. > > Steven Smith > > On Feb 4, 2006, at 1:03 PM, Dan Shafer wrote: > > > On another programming list on which I''m active, I''ve (of course) > > mentioned my newfound interest in and focus on Rails. One of the > > long-time members, a pretty thoughtful guy, has emailed me > > privately and asked me if I could point him to any Rails apps that > > were handling huge amounts of traffic. I''ve had the usual > > conversations with him about what scalability really means, how few > > sites need to handle huge amounts of traffic, how Rails is just one > > component of the landscape, etc. > > > > Still, he wants to know if I can point him to any large-scale apps > > done in Rails. Is there an answer to this question? Or is it just > > one of those diversionary issues raised by people who are looking > > for some reason not to spend the time to evaluate a new technology > > deeply enough to draw their own conclusions? > > > > Thanks. > > > > (I did look at http://wiki.rubyonrails.org/rails/pages/ > > RealWorldUsage but it''s impossible, of course, to tell which of > > those sites might be handling huge traffic volumes.) > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060204/2feb74f7/attachment.html
> A couple of the more well known applications would be 43 Things > (http://www.43things.com/) with somewhere between 500K and 1MM > requests per day and Basecamp (http://www.basecamphq.com/) with over > 100,000 users. Others on the list can probably give you more > specific examples for these two applications as well as others.I believe 43things/people/places.com has been doing 1MM+ requests for quite a while. The 37signals suite is doing more than 1.5MM+ requests these days as well. But these examples are not terribly interesting simply for the fact that scaling Rails is largely uninteresting. It''s a solved LAMP problem. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
I have a controller in which I define @responseAr as a new line from responses table def hello @stimuliAr = Stimuli.find_all @responseAr = Response.new end def knowname a_response = Response.create( :session_id => 1, :stimuli_id => 0, :keypress => 1, :name => responseAr.name) redirect_to :action => "hello" end in my hello.rhtml I have a form to collect a name to be store <%= start_form_tag(:action => "knowname") %> Name: <%= text_field("responseAr", "name") %> <%= submit_tag("Know Name") %> <% end_form_tag %> I can write to the database if I type :name => "testname") instead of :name => @responseAr.name) or :name => responseAr.name) How do I access responseAr.name which the form has saved to save it to the table? thank you for your help
Ian Harding
2006-Feb-05 22:00 UTC
[Rails] Re: baby step1 how to access a database without using scafold?
Hi! You need the Agile Web Development with Ruby on Rails book. And probably the "Pickaxe" book. www.pragmaticprogrammers.com On 2/4/06, Anne G <anne@wjh.harvard.edu> wrote:> > 1. I put a space in front of the password in database.yml, > after "password:" > 2. I rebooted the computer. > > It now seems to work. I am able to access all the > information. > > How can I generalise to several tables. I assume I > need one model per table? > > How do I write to a table? > > What do I need to understand about relational tables? > > thanks for a little help, this is good learning, but it is > so slow finding this info, most tutorials I looked at use > scaffold > > anne > > --------------------------------------------------- > > 1. I generated a model file stimuli.rb > > class Stimuli < ActiveRecord::Base > end > > 2. I have a controller and an action hello > > class RunexpController < ApplicationController > def hello > @stimuliAr = Stimuli.find_all > end > end > > 3. I have a viewing html > > <body> > <%= link_to @stimuliAr[0].image_url, :action => "show", :id > => @stimuliAr[0].id %> > </body> > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I found something that works, but I don''t understand it in my view page <%= text_field("responseAr", "name", "size" => "20") %> in my controller method a_response = Response.create( :session_id => 1, :stimuli_id => 0, :keypress => 1, :name => params[:responseAr]["name"]) It works, but I don''t understand it, what is pararams, the book says :variable, :attribute the default content is taken from @responseAr.name but why is the result not put there? how am I supposed to know it is in params? confused. The text does not show right away in the text box, why not? thanks for your help
anne g
2006-Feb-05 22:31 UTC
[Rails] Re: baby step1 how to access a database without usingscafold?
Ian Harding <harding.ian@...> writes:> > Hi! > > You need the Agile Web Development with Ruby on Rails book. And > probably the "Pickaxe" book.Yes, it does sound like that is my problem, isn''t it, but I have both, still it is all guess work. The info just isn''t there is in a way easy to grasp. What the book talks about is so much more complex than what I am trying to do that I just don''t find the info/examples.
Steve Longdo
2006-Feb-06 00:09 UTC
[Rails] Re: baby step1 how to access a database without usingscafold?
Are you sure that you are running Rails in development mode? You could also try setting up a different user for Rails to access MySQL. Try the following.>From mysql:create databasename; grant all on databasename.* to ''rails_user''@''localhost'' identified by ''password''; flush privileges; In your database.yml: development: adapter: mysql database: databasename username: rails_user password: password socket: /tmp/mysql.sock On 2/5/06, anne g <anne@wjh.harvard.edu> wrote:> > Ian Harding <harding.ian@...> writes: > > > > > Hi! > > > > You need the Agile Web Development with Ruby on Rails book. And > > probably the "Pickaxe" book. > > Yes, it does sound like that is my problem, isn''t it, but I have both, > still it is all guess work. The info just isn''t there is in a way easy to > grasp. What the book talks about is so much more complex than > what I am trying to do that I just don''t find the info/examples. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060206/8222e87f/attachment.html
anne g
2006-Feb-06 00:52 UTC
[Rails] Re: baby step1 how to access a database withoutusingscafold?
Here is what I learned after two days struggling with this: To read from a table stimulis, I can run @stimuliAr = Stimuli.find_all in the controller and I can now access any of the rows with something like @stimuliAr[0].image_url where image_url is one of my fields. then to capture a name from form and write to a table I created a new row in the controller @responseAr = Response.new <%= start_form_tag(:action => "sortresponse") %> Name: <%= text_field("responseAr", "name", "size" => "20") %> <%= submit_tag("Know Name") %> <% end_form_tag %> text field would use @responseAr.name I believe if it was not empty to put something in the box. the output of the form is in params. To look at params, run render_text @params.inspect in the controller. In my case I got something like {?commit?=>?Know Name?, ?action?=>?sortresponse?, ?controller?=>?runexp?, ?responseAr?=>{?name?=>?dud?}} so the form returns the label on the submit button (you can have several different submit buttons) which includes the data in params[:responseAr]["name"] to write this info to database, I wrote a_response = Response.create( :session_id => 1, :stimuli_id => 0, :keypress => 1, :name => params[:responseAr]["name"]) I am not sure the a_response = is necessary. this is how I wrote to the database. This may not be the cleanest way but that is what I learned with two days of work. I don''t know where to find that kind of reallly basic information. I hope this post will help someone else. What I need to do now is figure out session. Could someone give me an idea of how complicated session is? What are the steps I need to figure out. The book tutorial is too complex for me, and I don''t understand the reference section on session right now. I don''t want a login for right now, so the first time the page is accessed, I need to create a fake id I guess which will identify the computer.
David Heinemeier Hansson wrote:> But these examples are not terribly interesting simply for the fact > that scaling Rails is largely uninteresting. It''s a solved LAMP > problem.But the fact that the solution applies to Rails isn''t necessarily something people will assume, so that data point in itself is interesting. -- Alex
Dylan Stamat wrote:> Hey Dan ! > > I really dig this interview: > http://www.oreillynet.com/pub/wlg/8274?wlg=yesInteresting, though not much on the implementation details.> > Also, Ezra''s migration story is excellent: > http://brainspl.at/articles/2005/11/03/from-start-to-launch-http-yakimaherald-comAgain interesting, though it states that a lot of what''s being served is static content. "We are getting around 60,000+ hits a day and thanks rails page and fragment caching. This allows for content to be regenerated once after it is updated and then written to a static .html page that the webserver is able to serve at 1500+ requests/second. Then the next time an update is made to the content of any page that is cached, the cached file is regenerated as .html and served as a static page until the next update." That might not work if the content is broader than it is deep, that is, if you''re serving mostly user-specific pages or fragments of pages. The "Agile Web Development with Rails" book gives these examples: Basecamp by 37signals does 400,000 dynamic requests / day. The setup is two servers (dual 2.4ghx xeons w/2gb of RAM each), apache1.3, fcgi. rapidreporting.com tested it at 3000 req/sec on a test application, and the real one (production) does about 300 req/sec. They use lighttpd/fcgi. A bit more info''s in that book. Regards, Jim
David Heinemeier Hansson wrote: [...]> > But these examples are not terribly interesting simply for the fact > that scaling Rails is largely uninteresting. It''s a solved LAMP > problem.Yes and no. To oversimplify, if you need to be able to handle peaks of, say, 500 requests/second, and your Rails (or tomcat, or whatever) setup will handle 100, then 5 servers should do it. If your Rails app will only handle 5 requests/second, then you may be in trouble. So application performance can''t be ignored, and more specifically, solving the puzzle of Rails configuration for high performance is not trivial.
The "Agile Web Development with Rails" book gives these examples: Basecamp: 2 x 2.4ghz Xeons w/2gb RAM 15 fcgi processes and 50-100 apache1.3 processes 400,000 dynamic requests/day rapidreporting.com: 3000 req/sec on a test app across their 10 machine cluster 300 req/sec on their production environment lighttpd and 10 fastCGIs. More details in the book. Regards, Jim Dylan Stamat wrote:> Hey Dan ! > > I really dig this interview: > http://www.oreillynet.com/pub/wlg/8274?wlg=yes > > Also, Ezra''s migration story is excellent: > http://brainspl.at/articles/2005/11/03/from-start-to-launch-http-yakimaherald-com > > There are some others, but these two were enough to sell my employers on > using RoR instead of the J2ee or PHP solution they were about to use :) > => Dylan > > > On 2/4/06, Steven Smith <ssmith@fiveruns.com> wrote: > >>A couple of the more well known applications would be 43 Things >>(http://www.43things.com/) with somewhere between 500K and 1MM >>requests per day and Basecamp (http://www.basecamphq.com/) with over >>100,000 users. Others on the list can probably give you more >>specific examples for these two applications as well as others. >> >>Steven Smith >> >>On Feb 4, 2006, at 1:03 PM, Dan Shafer wrote: >> >> >>>On another programming list on which I''m active, I''ve (of course) >>>mentioned my newfound interest in and focus on Rails. One of the >>>long-time members, a pretty thoughtful guy, has emailed me >>>privately and asked me if I could point him to any Rails apps that >>>were handling huge amounts of traffic. I''ve had the usual >>>conversations with him about what scalability really means, how few >>>sites need to handle huge amounts of traffic, how Rails is just one >>>component of the landscape, etc. >>> >>>Still, he wants to know if I can point him to any large-scale apps >>>done in Rails. Is there an answer to this question? Or is it just >>>one of those diversionary issues raised by people who are looking >>>for some reason not to spend the time to evaluate a new technology >>>deeply enough to draw their own conclusions? >>> >>>Thanks. >>> >>>(I did look at http://wiki.rubyonrails.org/rails/pages/ >>>RealWorldUsage but it''s impossible, of course, to tell which of >>>those sites might be handling huge traffic volumes.) >>>_______________________________________________ >>>Rails mailing list >>>Rails@lists.rubyonrails.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Feb 6, 2006, at 8:13 AM, James Nachlin wrote:> David Heinemeier Hansson wrote: > [...] >> But these examples are not terribly interesting simply for the fact >> that scaling Rails is largely uninteresting. It''s a solved LAMP >> problem. > > Yes and no. To oversimplify, if you need to be able to handle > peaks of, say, 500 requests/second, and your Rails (or tomcat, or > whatever) setup will handle 100, then 5 servers should do it. If > your Rails app will only handle 5 requests/second, then you may be > in trouble. > > So application performance can''t be ignored, and more specifically, > solving the puzzle of Rails configuration for high performance is > not trivial.What''s non-trivial? It''s as easy, and thanks to lighhtpd (no, not part of Rails, but I thank Rails for introducing me to it!) easier than mod_perl, and the same as anything else running FCGI... -- Tom Mornini
> > But these examples are not terribly interesting simply for the fact > > that scaling Rails is largely uninteresting. It''s a solved LAMP > > problem. > > Yes and no. To oversimplify, if you need to be able to handle peaks of, > say, 500 requests/second, and your Rails (or tomcat, or whatever) setup > will handle 100, then 5 servers should do it. If your Rails app will > only handle 5 requests/second, then you may be in trouble. > > So application performance can''t be ignored, and more specifically, > solving the puzzle of Rails configuration for high performance is not > trivial.Oh, scaling is never "easy". It''s just that its a known, well-described problem. We know what the elements and techniques are. And they''re "boring" in Rails because they''re roughly the same as with any other LAMP stack. Now performance on a particular project can always be a bitch, but it''s rarely so much about Rails as its about the business logic. And of course, performance is different than scaling. You might have terrible performance, like 5 req/sec, but still be able to throw tons of hardware after it and still scale. And depending on your business model, that might well still be immensely profitable. The cost per request just needs to be less than the value of it. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
On Feb 6, 2006, at 8:00 AM, Jim Nachlin wrote:> Dylan Stamat wrote: >> Hey Dan ! >> I really dig this interview: >> http://www.oreillynet.com/pub/wlg/8274?wlg=yes > > Interesting, though not much on the implementation details. > >> Also, Ezra''s migration story is excellent: >> http://brainspl.at/articles/2005/11/03/from-start-to-launch-http- >> yakimaherald-com > > Again interesting, though it states that a lot of what''s being > served is static content. "We are getting around 60,000+ hits a > day and thanks rails page and fragment caching. This allows for > content to be regenerated once after it is updated and then written > to a static .html page that the webserver is able to serve at 1500+ > requests/second. Then the next time an update is made to the > content of any page that is cached, the cached file is regenerated > as .html and served as a static page until the next update." > > That might not work if the content is broader than it is deep, that > is, if you''re serving mostly user-specific pages or fragments of > pages. > > The "Agile Web Development with Rails" book gives these examples: > Basecamp by 37signals does 400,000 dynamic requests / day. The > setup is two servers (dual 2.4ghx xeons w/2gb of RAM each), > apache1.3, fcgi. rapidreporting.com tested it at 3000 req/sec on a > test application, and the real one (production) does about 300 req/ > sec. They use lighttpd/fcgi. > > A bit more info''s in that book. > > Regards, > JimJim- I wrote that article in September of 05 when we launched the new site. And yes most stuff was cached then. Since then our traffic has increased quite a bit. Yesterday we served about 50,000+ cached page views and about 45,000+ dynamic page views. This is because we have added a bunch of functionality to the application and a lot of it cannot be page cached. But the whole site runs off of one dual xserve and we have tons of room to grow still. My estimate is that we will be able to keep up with 400-500k page views/day before we will need any new hardware. Some of this performance increase is because the initial launch of the site was on rails 0.12 - 0.13, I don''t remember exactly which one. But running under rails 1.0.0 is much faster and the performance keeps getting better. Also, most very high traffic sites will make good use of caching everywhere they can. Its mostly about finding the balance between the functionality you need per page and your caching options available for said page. I have no reservations that rails can handle as big of a site as you want. You just need to make the right decisions about your apps design and get the right hardware for the amount of traffic you expect to serve. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com
Tom Mornini wrote: [...]>> So application performance can''t be ignored, and more specifically, >> solving the puzzle of Rails configuration for high performance is not >> trivial. > > > What''s non-trivial? > > It''s as easy, and thanks to lighhtpd (no, not part of Rails, but I > thank Rails for introducing me to it!) easier than mod_perl, and the > same as anything else running FCGI...This is a serious question. Supposing that lighttpd is not suitable to your application, or you can''t use it for some reason [*], then you can use Apache 1.3 or 2, as I have been trying to do. Setting up fastcgi using "external", I find there are many times when Rails does not give an error message with any information, just a 500 or a blank response. If dispatch.fcgi dies when started as an external server, it dies w/o error. There is little documentation on how to do this. So, it was a struggle for me. Eventually, I did get it working [**] thanks to the people on this list, but there are still serious issues. This is not to put any blame on the Rails team. It is just a newish system. The fcgi documentation is sparse as well, and error reporting there is not great. So, non-trivial, overall. Regards, Jim * http://article.gmane.org/gmane.comp.web.lighttpd/3287 ** INITIAL RUBY ON RAILS BENCHTEST This is on a laptop running linux 2.6, 512MB RAM, 1.7 GHz pentium M. These figures are for relative comparison only, and do not reflect how these systems would run on a well-tuned server. The person who set these up has several years using the Apache httpd on a professional, high volume web site, and has no experience (<1 month) with lighttpd. STATIC PAGE FOR COMPARISON: $ ab -c10 -n1000 -k http://ruby.local:8000/index.html Apache/2.0.53, fcgi: 564.99 [#/sec] (mean) Apache/1.3.34, fcgi: 1236.24 [#/sec] (mean) lighttpd 1.4.9, fcgi: 3270.16 [#/sec] (mean) DUMMY RAILS CONTROLLER: $ script/generate controller foo hello $ ab -c10 -n1000 -k http://ruby.local:8000/foo/hello Apache/2.0.53, fcgi: 9.65 [#/sec] (mean) <---- using "dynamic" fcgi method 10.13 [#/sec] (mean) <---- using "static" with -processes 2 9.98 [#/sec] (mean) <---- using "static" with -processes 4 136.24 [#/sec] (mean) <---- using "external" with tcp sock ** Apache/1.3.34, fcgi: * Apache/2.0.53, cgi: 0.79 [#/sec] (mean) lighttpd 1.4.9, fcgi: 195.70 [#/sec] (mean) <---- using "external" with tcp sock *** $ ab -c100 -n10000 -k http://ruby.local:8000/foo/hello Apache/2.0.53, fcgi: 109.79 [#/sec] <---- using "external" with tcp sock ** NOTES * Can''t get it working. Fails w/ only a "500" from server, no further error msg. ** This method seems to support only one external fcgi server under Apache, essentially giving you a single-threaded server. spin script: #!/bin/sh /home/jim/rubystuff/testapp/script/process/spinner \ -c ''/home/jim/rubystuff/testapp/script/process/spawner -p 19999 -i 1 '' \ -d *** hint: delete the /tmp/ruby-sess* files owned by root
Ezra Zygmuntowicz wrote: [...]> Jim- > > I wrote that article in September of 05 when we launched the new > site. And yes most stuff was cached then. Since then our traffic has > increased quite a bit. Yesterday we served about 50,000+ cached page > views and about 45,000+ dynamic page views. This is because we have > added a bunch of functionality to the application and a lot of it > cannot be page cached. > > But the whole site runs off of one dual xserve and we have tons of > room to grow still. My estimate is that we will be able to keep up with > 400-500k page views/day before we will need any new hardware. Some of > this performance increase is because the initial launch of the site was > on rails 0.12 - 0.13, I don''t remember exactly which one. But running > under rails 1.0.0 is much faster and the performance keeps getting better. > > Also, most very high traffic sites will make good use of caching > everywhere they can. Its mostly about finding the balance between the > functionality you need per page and your caching options available for > said page. > > I have no reservations that rails can handle as big of a site as > you want. You just need to make the right decisions about your apps > design and get the right hardware for the amount of traffic you expect > to serve.[...] Hi Ezra, This is very good to hear, but so far I can''t reproduce these results or anything near them using I need to use Apache. So far it seems that with fcgi external servers Rails will run single-threaded, and with "static" or "dynamic" fcgi, performance is <10 req/sec. on my test box. I know that people have made this work, and that Rails will scale, it is just a matter of figuring out how, which I have not done yet. Jim
<10/second sounds like you''re CGI, not FCGI. -- -- Tom Mornini On Feb 6, 2006, at 10:56 AM, James Nachlin wrote:> This is very good to hear, but so far I can''t reproduce these > results or anything near them using > > I need to use Apache. So far it seems that with fcgi external > servers Rails will run single-threaded, and with "static" or > "dynamic" fcgi, performance is <10 req/sec. on my test box. > > I know that people have made this work, and that Rails will scale, > it is just a matter of figuring out how, which I have not done yet.
Tom Mornini wrote:> <10/second sounds like you''re CGI, not FCGI. > > -- -- Tom Mornini >No. CGI is <1/sec. If anyone''s getting better performance with FCGI dynamic or static on Apache2, I''d like to hear how. Glad to share my httpd.conf and anything else. Sincerely, Jim Nachlin
On Feb 6, 2006, at 10:56 AM, James Nachlin wrote:> > > Ezra Zygmuntowicz wrote: > [...] >> Jim- >> I wrote that article in September of 05 when we launched the >> new site. And yes most stuff was cached then. Since then our >> traffic has increased quite a bit. Yesterday we served about >> 50,000+ cached page views and about 45,000+ dynamic page views. >> This is because we have added a bunch of functionality to the >> application and a lot of it cannot be page cached. >> But the whole site runs off of one dual xserve and we have >> tons of room to grow still. My estimate is that we will be able >> to keep up with 400-500k page views/day before we will need any >> new hardware. Some of this performance increase is because the >> initial launch of the site was on rails 0.12 - 0.13, I don''t >> remember exactly which one. But running under rails 1.0.0 is much >> faster and the performance keeps getting better. >> Also, most very high traffic sites will make good use of >> caching everywhere they can. Its mostly about finding the balance >> between the functionality you need per page and your caching >> options available for said page. >> I have no reservations that rails can handle as big of a site >> as you want. You just need to make the right decisions about your >> apps design and get the right hardware for the amount of traffic >> you expect to serve. > [...] > > Hi Ezra, > > This is very good to hear, but so far I can''t reproduce these > results or anything near them using > > I need to use Apache. So far it seems that with fcgi external > servers Rails will run single-threaded, and with "static" or > "dynamic" fcgi, performance is <10 req/sec. on my test box. > > I know that people have made this work, and that Rails will scale, > it is just a matter of figuring out how, which I have not done yet. > > JimJim- I first launched the newspaper site under apache1.3.x/fcgi and soon realized how it wasn''t performing very well at all for dynamic pages. And apache/fcgi is notorious for those random 500 error messages that are intermittent. So after using apache/fcgi for the site for one week I decided to use lighttpd instead. The difference was black and white. Apache is a great all around webserver and can do a great job for some rails apps. But I have found that lighttpd was so much faster and so much more stable for me that the only time I use apache with my rails projects now is as a front end proxy to lighty on a higher port. Even with the overhead of apache->lighty->rails->lighty- >apache, this set up was faster then standalone apache/fcgi. I understand that people are very used to apache servers and may be reluctant to switch to lighty. But this will be a serious impediment to your production environment until the new mod_proxy_fcgi comes out for apache. i am hoping that that new apache module will solve these problems. But for right now, lighty is IMHO the better choice for most rails applications. Feel free to contact me off list. I would be happy to share configuration files with you if you need. Cheers- -Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com
I must now recant some of my previou statements. There was an error in my httpd.conf such that the "-initial-env RAILS_ENV=test" was not getting passed. This means that the benchtest was running in development mode under apache2. I am now getting >100 req/sec in test or production mode, using the dynamic fcgi method and unix sockets! Regards, Jim James Nachlin wrote:> Tom Mornini wrote: > >> <10/second sounds like you''re CGI, not FCGI. >> >> -- -- Tom Mornini >> > > No. CGI is <1/sec. If anyone''s getting better performance with FCGI > dynamic or static on Apache2, I''d like to hear how. Glad to share my > httpd.conf and anything else. > > Sincerely, > Jim Nachlin > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I wanted session to store the key to the stimulis table row being viewed in the Subjects table. Trying to mimick the cart example in the book, I started with the line session[:runexp] ||= Subject.new where subjects is a table, subject.rb a model... that line causes an error It turns out session[:runexp] ||= Subject.id does not give an error, so for now, I will just store single values in session. But what do I need to do so this session is stored in a database? Right now, I think it is stored in memory. thank you for your help. anne
I saw this information To use ActiveRecord as a session storage mechanism, you will need a table in your database named sessions: CREATE TABLE sessions ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, sessid CHAR(32), data TEXT, PRIMARY KEY(id), INDEX(sessid) ); http://wiki.rubyonrails.com/rails/pages/HowtoChangeSessionStore but I don''t know what I am supposed to do with it? how do I use it with the session method? anne On Tue, 7 Feb 2006, Anne G wrote:> I wanted session to store the key to the stimulis table row > being viewed in the Subjects table. > > Trying to mimick the cart example in the book, I started > with the line > > session[:runexp] ||= Subject.new > > where subjects is a table, subject.rb a model... > that line causes an error > > It turns out > session[:runexp] ||= Subject.id > > does not give an error, so for now, I will just store single > values in session. > > But what do I need to do so this session is stored > in a database? Right now, I think it is stored in memory. > > thank you for your help. > > anne > > > > > > >
Anne G wrote:> I wanted session to store the key to the stimulis table row > being viewed in the Subjects table.Ok...> session[:runexp] ||= Subject.new > > where subjects is a table, subject.rb a model... > that line causes an errorWhat''s the error? It looks OK to me.> It turns out > session[:runexp] ||= Subject.idI very much doubt that''s doing what you think it is, or what you want. It''s not doing anything to do with the database, for a start.> does not give an error, so for now, I will just store single > values in session. > > But what do I need to do so this session is stored > in a database? Right now, I think it is stored in memory.Uncomment this line in config/environment.rb: # config.action_controller.session_store = :active_record_store and run rake create_sessions_table in the root directory of your app. Now for the next question: why do you want to store the session in the database? I think you might be trying to do something else, and might have the terminology mixed up. Apologies if that''s not the case, but worrying about where the session is stored is usually something that gets dealt with later in the development cycle. Feel free to email me off-list if you want. -- Alex