only session[] and flash[] are retained between calls IIRC. Of course, if you use something like memcached that will persist as well.
On May 5, 8:57 am, Chris Apolzon <[email protected]> wrote: > Matt- > I can't begin to thank you enough for your feedback. Working on my first > major rails project as the sole developer (and not a single minute of Ruby > experience anywhere else in the office) makes it extremely difficult to get > good feedback. > > I love your nav-item-with-count tag and I removed the ||= in my controller > logic. Would it make sense to change any of those instance variables to a > normal ruby variable? Or would I need to do some cache checks in that case > to make sure I didn't serve stale data? > > I have run into a couple issues in the nav-item-with-count tag, though. > First, the link_text assignment isn't correct as the empty tag case > (<nav-item-with-count status="something"/>) parameters.default returns "" > which overrides the || status chunk. (Easily fixable) > > The other issue is Manuscript.send("status_name") returns undefined method > "status_name". I will eventually be implementing these as lifecycles; is > this one of the things I'll get for free when I switch over to a lifecycle? > I'm working on a short-term fix, but I'm not really sure how that line was > supposed to work originally. > > Thanks again for the help. > > > > On Tue, May 4, 2010 at 3:44 PM, Matt Jones <[email protected]> wrote: > > On Tue, May 4, 2010 at 3:16 PM, Chris Apolzon <[email protected]> wrote: > > > Well I managed to scrap something together. Here's my code: > > > [...snip...] > > > before_filter :setup_counts > > > def seeking_reviewers > > > hobo_index @seeking_reviewers ||= > > Manuscript.search("seeking_reviewers", > > > :status) > > > end > > > Couple things: > > > - the ||= here is not needed; controller instance variables (with an > > @) are not persisted between requests. > > > - the search scope is extreme overkill here; you'll get a much more > > efficient DB query (= rather than LIKE) with > > status_is('seeking_reviewers'). OR, if the status is implemented as a > > lifecycle (which it probably should be), then you'll get scopes like > > seeking_reviewers for free. > > > > And then, in my main-nav definition: > > > <nav-item href="&received_manuscripts_path">Received (<%= @received_count > > > %>)</nav-item> > > > <nav-item href="&seeking_reviewers_manuscripts_path">Seeking Reviewers > > (<%= > > > @seeking_reviewers_count %>)</nav-item> > > > <nav-item href="&at_review_manuscripts_path">At Review (<%= > > @at_review_count > > > %>)</nav-item> > > > <nav-item href="&back_from_review_manuscripts_path">Back From Review (<%= > > > @back_from_review_count %>)</nav-item> > > > <nav-item href="&pending_resubmission_manuscripts_path">Pending > > Resubmission > > > (<%= @pending_resubmission_count %>)</nav-item> > > > You might be better off defining a specific tag to handle this (the > > DRY in DRYML): > > > <def tag="nav-item-with-count" attrs="status"> > > <% link_text = parameters.default || status.humanize.titleize %> > > <% href = send("#{status}_manuscripts_path") %> > > <nav-item href="#{href}"><%= link_text %> (<%= > > Manuscript.send(status).count %>)</nav-item> > > </def> > > > This will simplify your main-nav to: > > > <nav-item-with-count status="received" /> > > <nav-item-with-count status="seeking_reviewers" /> > > > Or, you can customize the link text: > > > <nav-item-with-count status="received">Some Other > > Title</nav-item-with-count> > > > Which will change the text, but keep the count in parentheses. > > > > And finally, is there a way to print an instance variable using the view: > > > tag? > > > You can always do: > > > <view with="&@some_instance_var /> > > > which should trigger the correct view tag. > > > --Matt Jones > > > -- > > You received this message because you are subscribed to the Google Groups > > "Hobo Users" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<hobousers%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/hobousers?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Hobo Users" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/hobousers?hl=en. -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
