Hi, I''ve created a Rails application and am having a problem listing by a particular category in an associated table. I followed the instructions found at the O''Reilly tutorial (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) but have not had success. Can anyone please outline a better set of instructions than in the "Showing Recipes in a Category" section? Thank you for your time! Melanie
Hey! ... I saw that .. apparently you are a girl programmer? so am I .. there seems to be so few of us! I just wondered if perhaps you wanted to be friends? I''m 28 and live near Chicago, IL. I''ve been a programmer for past 8 years. I''ve been doing PHP post of that time On 3/3/06, Melanie C. <k_rabbit@hotmail.com> wrote:> Hi, > > I''ve created a Rails application and am having a problem listing by a > particular category in an associated table. I followed the instructions > found at the O''Reilly tutorial > (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) but have > not had success. Can anyone please outline a better set of instructions > than in the "Showing Recipes in a Category" section? Thank you for your > time! > > Melanie > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://PhpGirl.blogger.com http://CodeSnipers.com
Hi Nola, and other Railschix (to coin a term), Are you familiar with the Linuxchix lists? LOTS of girl programmers there, and in fact girl techies of all sorts. A lot of times, it''s nice to have a community of *female* experts. Meaning no offence to anyone here ;) Check them out at http://www.linuxchix.com/ Rachel Nola Stowe wrote:> Hey! ... I saw that .. apparently you are a girl programmer? so am I > .. there seems to be so few of us! I just wondered if perhaps you > wanted to be friends? > > I''m 28 and live near Chicago, IL. I''ve been a programmer for past 8 > years. I''ve been doing PHP post of that time > > On 3/3/06, Melanie C. <k_rabbit@hotmail.com> wrote: > >>Hi, >> >>I''ve created a Rails application and am having a problem listing by a >>particular category in an associated table. I followed the instructions >>found at the O''Reilly tutorial >>(http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) but have >>not had success. Can anyone please outline a better set of instructions >>than in the "Showing Recipes in a Category" section? Thank you for your >>time! >> >>Melanie >> >> >>_______________________________________________ >>Rails mailing list >>Rails@lists.rubyonrails.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > > -- > http://PhpGirl.blogger.com > http://CodeSnipers.com > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I find it fascinating that for decades (if not millenia!) women have been striving for a much deserved equality, and then now that they''re so much closer than they have ever been to achieving that ideal they perpetuate the grand old tradition of same sex institutions which have historically been the ire of their movement in the form of Men''s clubs. I suppose the difference is that it''s a choice they''ve made, rather than a choice made for them. In any case, welcome all Rails and Linux Chixs! -- -- Tom Mornini On Mar 3, 2006, at 9:58 PM, Rachel McConnell wrote:> Hi Nola, and other Railschix (to coin a term), > > Are you familiar with the Linuxchix lists? LOTS of girl > programmers there, and in fact girl techies of all sorts. A lot of > times, it''s nice to have a community of *female* experts. Meaning > no offence to anyone here ;) > > Check them out at > > http://www.linuxchix.com/ > > Rachel > > Nola Stowe wrote: >> Hey! ... I saw that .. apparently you are a girl programmer? so am I >> .. there seems to be so few of us! I just wondered if perhaps you >> wanted to be friends? >> I''m 28 and live near Chicago, IL. I''ve been a programmer for past 8 >> years. I''ve been doing PHP post of that time >> On 3/3/06, Melanie C. <k_rabbit@hotmail.com> wrote: >>> Hi, >>> >>> I''ve created a Rails application and am having a problem listing >>> by a >>> particular category in an associated table. I followed the >>> instructions >>> found at the O''Reilly tutorial >>> (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) >>> but have >>> not had success. Can anyone please outline a better set of >>> instructions >>> than in the "Showing Recipes in a Category" section? Thank you >>> for your >>> time!
Sorry for continuing off topic, but I want to correct a misconception I inadvertently propagated (say that 5 times fast) plus correct a dumb typo. Linuxchix isn''t women only. Men are welcome on all but one of the 7 or 8 (I forget exactly) lists - and the women-only one isn''t the heaviest trafficked one by a long shot. And the real URL is http://www.linuxchix.org/ And Tom, thanks for the welcome! I''ve already gotten some much-needed assistance here and hopefully will soon be able to contribute as well. Rachel PS- Tom, I have lots of thoughts on same-sex institutions, but I''ll keep that off this list. Feel free to email me directly if you want to have that conversation ;) Tom Mornini wrote:> I find it fascinating that for decades (if not millenia!) > women have been striving for a much deserved equality, and > then now that they''re so much closer than they have ever > been to achieving that ideal they perpetuate the grand old > tradition of same sex institutions which have historically > been the ire of their movement in the form of Men''s clubs. > > I suppose the difference is that it''s a choice they''ve > made, rather than a choice made for them. > > In any case, welcome all Rails and Linux Chixs! > > -- -- Tom Mornini > > On Mar 3, 2006, at 9:58 PM, Rachel McConnell wrote: > >> Hi Nola, and other Railschix (to coin a term), >> >> Are you familiar with the Linuxchix lists? LOTS of girl programmers >> there, and in fact girl techies of all sorts. A lot of times, it''s >> nice to have a community of *female* experts. Meaning no offence to >> anyone here ;) >> >> Check them out at >> >> http://www.linuxchix.com/ >> >> Rachel >> >> Nola Stowe wrote: >> >>> Hey! ... I saw that .. apparently you are a girl programmer? so am I >>> .. there seems to be so few of us! I just wondered if perhaps you >>> wanted to be friends? >>> I''m 28 and live near Chicago, IL. I''ve been a programmer for past 8 >>> years. I''ve been doing PHP post of that time >>> On 3/3/06, Melanie C. <k_rabbit@hotmail.com> wrote: >>> >>>> Hi, >>>> >>>> I''ve created a Rails application and am having a problem listing by a >>>> particular category in an associated table. I followed the >>>> instructions >>>> found at the O''Reilly tutorial >>>> (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) >>>> but have >>>> not had success. Can anyone please outline a better set of >>>> instructions >>>> than in the "Showing Recipes in a Category" section? Thank you for >>>> your >>>> time! > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I''ve seen the linuxchix site and recently started a similar thing ... I started a message board at www.devchix.com .. if interested, send me an email. On 3/4/06, Rachel McConnell <rachel@xtreme.com> wrote:> Sorry for continuing off topic, but I want to correct a misconception I > inadvertently propagated (say that 5 times fast) plus correct a dumb typo. > > Linuxchix isn''t women only. > > Men are welcome on all but one of the 7 or 8 (I forget exactly) lists - > and the women-only one isn''t the heaviest trafficked one by a long shot. > > And the real URL is > > http://www.linuxchix.org/ > > And Tom, thanks for the welcome! I''ve already gotten some much-needed > assistance here and hopefully will soon be able to contribute as well. > > Rachel > > > PS- Tom, I have lots of thoughts on same-sex institutions, but I''ll keep > that off this list. Feel free to email me directly if you want to have > that conversation ;) > > Tom Mornini wrote: > > I find it fascinating that for decades (if not millenia!) > > women have been striving for a much deserved equality, and > > then now that they''re so much closer than they have ever > > been to achieving that ideal they perpetuate the grand old > > tradition of same sex institutions which have historically > > been the ire of their movement in the form of Men''s clubs. > > > > I suppose the difference is that it''s a choice they''ve > > made, rather than a choice made for them. > > > > In any case, welcome all Rails and Linux Chixs! > > > > -- -- Tom Mornini > > > > On Mar 3, 2006, at 9:58 PM, Rachel McConnell wrote: > > > >> Hi Nola, and other Railschix (to coin a term), > >> > >> Are you familiar with the Linuxchix lists? LOTS of girl programmers > >> there, and in fact girl techies of all sorts. A lot of times, it''s > >> nice to have a community of *female* experts. Meaning no offence to > >> anyone here ;) > >> > >> Check them out at > >> > >> http://www.linuxchix.com/ > >> > >> Rachel > >> > >> Nola Stowe wrote: > >> > >>> Hey! ... I saw that .. apparently you are a girl programmer? so am I > >>> .. there seems to be so few of us! I just wondered if perhaps you > >>> wanted to be friends? > >>> I''m 28 and live near Chicago, IL. I''ve been a programmer for past 8 > >>> years. I''ve been doing PHP post of that time > >>> On 3/3/06, Melanie C. <k_rabbit@hotmail.com> wrote: > >>> > >>>> Hi, > >>>> > >>>> I''ve created a Rails application and am having a problem listing by a > >>>> particular category in an associated table. I followed the > >>>> instructions > >>>> found at the O''Reilly tutorial > >>>> (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) > >>>> but have > >>>> not had success. Can anyone please outline a better set of > >>>> instructions > >>>> than in the "Showing Recipes in a Category" section? Thank you for > >>>> your > >>>> time! > > > > > > _______________________________________________ > > 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 >-- http://PhpGirl.blogger.com http://CodeSnipers.com
Rachel > http://www.linuxchix.org/ I searched for the shop where I could buy the "LinuxChix Wet T-shirt", but I couldn''t find it. (sorry, I couldn''t resist.) To rant a little, what''s next? DemocratsRuby.org RubyForBlacks or a Debian distribution for GOP, with weakened encryption and mandatory backdoors? In forums and mailing lists, nobody cares if you''re ugly, fat or even if you''re a woman, as long as you are polite and don''t ask stupid questions? When I look around me, women are as rare as they are welcome in the IT techies world. Good code is good code. I read "why linuxchix exists" but I didn''t get it. It must be this Mars-Venus thing. I also checked UbuntuWomen, but I find it even worse. Alain
As a fellow female programmer I just have to say that David Heinemeier Hansson is very good looking :-) So there goes all my credability as a female programmer. -- Aneesha -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060304/357946f5/attachment.html
Everyone else, I won''t feed the trolls any more, I promise! But Alain, and anyone who thinks he might just have a point, please do your research first. Start here: http://www.tldp.org/HOWTO/Encourage-Women-Linux-HOWTO/ Rachel Alain Ravet wrote:> Rachel > > http://www.linuxchix.org/ > > I searched for the shop where I could buy the "LinuxChix Wet T-shirt", > but I couldn''t find it. > (sorry, I couldn''t resist.) > > > To rant a little, what''s next? > DemocratsRuby.org > RubyForBlacks > or a Debian distribution for GOP, with weakened encryption and mandatory > backdoors? > > > In forums and mailing lists, nobody cares if you''re ugly, fat or even if > you''re a woman, as long as you are polite and don''t ask stupid questions? > When I look around me, women are as rare as they are welcome in the IT > techies world. Good code is good code. > > I read "why linuxchix exists" but I didn''t get it. It must be this > Mars-Venus thing. > I also checked UbuntuWomen, but I find it even worse. > > > Alain > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Melanie C. wrote:> Hi, > > I''ve created a Rails application and am having a problem listing by a > particular category in an associated table. I followed the instructions > found at the O''Reilly tutorial > (http://www.onlamp.com/pub/a/onlamp/2005/03/03/rails.html?page=3) but > have not had success. Can anyone please outline a better set of > instructions than in the "Showing Recipes in a Category" section? Thank > you for your time![Just in case this is what you are stuck on, did you miss the <% end %> required to match the <% if ... %> added in recipe/list.rhtml? If that''s not the answer, read on.] Assuming everything was still working at the end of page 2, here''s a breakdown of what is added in "Showing Recipes in a Category": 1) The user needs to be able to choose which category to focus on. This is enabled by turning the category name, displayed in the list, into a link. It was <td><%= recipe.category.name %></td> and it becomes <%= link_to recipe.category.name, :action => "list", :category => "#{recipe.category.name}" %> </td> This is a link to the "list" action in the current controller, and it also provides a "category" parameter whose value is the name of the category of the recipe. [I don''t know why Curt used "#{recipe.category.name}" rather than recipe.category.name - either works for me.] If you *just* make this change to the recipe list.rhtml, the list should still work, the link should show, and when you hover over it (or view its source in the browser) you should see a URL like http://127.0.0.1:3000/recipe/list?category=Snacks ...but if you click on it, you should still see the *whole* list, because nothing has been done to capture that parameter and use it to filter the list. 2) In the RecipeController, the following line is added to the list method: @category = @params[''category''] This captures the value of the "category" parameter from the HTTP request, and puts it in the @category instance variable of the RecipeController instance handling the request. If there is no "category" parameter - as when you list all recipes - @category will be nil. Rails "magically" makes all the controller''s instance variables available to the view. The whole of the list method is now: def list @category = @params[''category''] @recipes = Recipe.find_all end When the list action has executed, Rails will (by default) use a template of the same name (list.rhtml) to render the response. As well as putting the category name (or nil) in @category, the action has put an array of all the recipes in @recipes. If you make this change, everything should still work, but the list will still show all the recipes. [In a real application, which might have thousands of recipes, you would expect the filtering by category to be done in the database query, but Curt has kept the original Recipe.find_all and put the filtering in the view.] [In the year since this article was published there have been many changes in Rails, and corresponding changes in recommended programming style. These days you would write: def list @category = params[''category''] @recipes = Recipe.find(:all) end ...but the old forms still work, for backwards compatibility.] 3) The final change is to filter the list in the view, if @categories is not nil. In the recipes list.rhtml, the control structure <% @recipes.each do |recipe| %> ... <% end %> becomes <% @recipes.each do |recipe| %> <% if (@category == nil) || (@category == recipe.category.name)%> ... <% end %> <% end %> So a recipe is only displayed as a row in the list if its category name is the same as @category, or if @category is nil. Oh - Curt didn''t point out in his description that the <% if ... %> needs a corresponding <% end %> - perhaps that was your problem. I hope this helps - if not, please tell us more about the symptoms. Justin
Hi, Wow, thank you for your explanation! It was very valuable in helping me find where the problem resides. The application I''ve built has many listing pages and multiple controllers and at this point I''m outside the realm of the scaffolding. [For example sake, however, I will refer to the recipes application.] When I hover over the category I see that the URL has the category selected, but when it directs to a new page, all of the recipes are listed. At this point, I think I need help in displaying the single category in a new listing page since I''m not using the scaffolding. Below are two examples of this. [Taken from list2, where it selects the category] <% @gisrs.each do |gisr| %> <% if (@employee == nil) || (@employee == gisr.employee.name)%> <tr> <td><%= link_to gisr.employee.name, :action => "list3", :employee => gisr.employee.name %></td> <% end %> <% end %> [Taken from list3, as stated in the action direction] <% @gisrs.each do |gisr| %> <td><%= gisr.employee.name%></td> <% end %> It makes sense to me why it''s listing all the "recipes" in list3... I just don''t know how to change it! Thanks for your help in this matter - I appreciate all of your time!
Nola: http://PhpGirl.blogger.com seems to be down... at least I can''t reach it... Aneesha: Doesn''t DHH have a girl friend or even wife already? :-) - Raphael -- Posted via http://www.ruby-forum.com/.
Melanie C. wrote:> Hi, > > Wow, thank you for your explanation! It was very valuable in helping me > find where the problem resides. The application I''ve built has many > listing pages and multiple controllers and at this point I''m outside the > realm of the scaffolding. [For example sake, however, I will refer to > the recipes application.] When I hover over the category I see that the > URL has the category selected, but when it directs to a new page, all of > the recipes are listed. > > At this point, I think I need help in displaying the single category in > a new listing page since I''m not using the scaffolding. Below are two > examples of this. > > [Taken from list2, where it selects the category] > <% @gisrs.each do |gisr| %> > <% if (@employee == nil) || (@employee == gisr.employee.name)%> > <tr> > <td><%= link_to gisr.employee.name, :action => "list3", :employee => > gisr.employee.name %></td> > <% end %> > <% end %> > > [Taken from list3, as stated in the action direction] > <% @gisrs.each do |gisr| %> > <td><%= gisr.employee.name%></td> > <% end %> > > It makes sense to me why it''s listing all the "recipes" in list3... I > just don''t know how to change it!Still following the approach in the cookbook tutorial (i.e. filtering in the view rather than in the query - not the most efficient approach, but that may not matter if you don''t have too much data or too many concurrent users) I assume that in the controller, in the list3 action, you have @employee = params[''employee''] (or @employee = @params[''employee''] if you are still using the old style) Then the filtering needs to be in list3, rather than list2, i.e. move the <% if (@employee == nil) || (@employee == gisr.employee.name)%> ... <% end %> into list3. Does that make sense?> Thanks for your help in this matter - > I appreciate all of your time!You are welcome Justin
I''m following the cookbook example on O''Reilly and I''ve managed to show all the recipes in a specific category via the list?category=Whatever url. I was wondering, is it possible to achieve the very same result with a so-called Pretty URL, like http://www.site.com/list/Whatever or www.site.com/Whatever/ ? Thanks, Andre. -- Posted via http://www.ruby-forum.com/.