search for: to_sentence

Displaying 6 results from an estimated 6 matches for "to_sentence".

2007 Jan 20
2
Conditional pluralize without the number
Hi. Assume you have an array of person names. I want to generate results in my view that look like this: Abby is your friend or Abby, Bob, and Carol are your friends. So I''d like to say: <%= friends.to_sentence %> <%= pluralize(friends.count, "is") %> your <%= pluralize(friends.count, "friend") %> But because pluralize puts in the number, I get: Abby 1 is your 1 friend or Abby, Bob, and Carol 3 are your 3 friends. Is there a way around this? The API only sho...
2007 Dec 07
2
[ActiveSupport] Patches needing review: re-organization of #to_query methods, preservation of XML/JSON content-type
...ry in the right places in ActiveSupport - http://dev.rubyonrails.org/ticket/10395 Preserve user-specified content type for XML and JSON rendering (currently it''s overridden and set to Mime::XML/Mimi::JSON - http://dev.rubyonrails.org/ticket/10388 Oh and a tiny patch for inconsistency in #to_sentence: http://dev.rubyonrails.org/ticket/10390 and a trivial doc patch for Date.yesterday and Date.today: http://dev.rubyonrails.org/ticket/10375 Reviews appreciated! Thanks! Cheers, Chu Yeow PS Rails 2.0 is almost here it seems: http://dev.rubyonrails.org/changeset/8321 --~--~---------~--~----~------...
2007 Oct 08
1
Can you alias fields in acts_as_ferret?
...Article model that has_many Authors. I want to be able to index authors'' names with each article. Since @article.authors yields an array of Author objects (and not an indexable string), I''ve created this method in my Article model: def authors_aaf @authors.collect {|a| a.name }.to_sentence end I call it "authors_aaf" because "authors" would cause a conflict. But I want my field name to be "authors", because that makes the most sense. (Users shouldn''t have to type "authors_aaf:Joe" to search by author.) Any idea how this can/should be...
2006 Aug 07
1
Eager loading wierdness
...Normally you would do this.. @items = Item.find(:all, :conditions=>["features.name = ?", ''foo''], :include=>:features) This all works fine and dandy except for this problem. If you do this... <% for item in @items %> <%= item.features.map {|x| x.name}.to_sentence %> <% end %> you only get the features listed that match the search criteria. If the item object has 10 different features associated and you search for one, the .features association only returns the one you searched on instead of the entire list of associated objects. Anyone kno...
2009 Oct 28
2
How to send a html email with attachment
Hi guys: I wanna send a html format email with a attachment. What I do is like: model: def weekly_report address = WeeklyReportEmail.find_all_by_validate(true).collect(&:address).to_sentence(:last_word_connector => '','', :two_words_connector => '','') @recipients = address @from = "Chronos weekly report <chronos-4ZJPdxLVsvDgESyFIoI21jfzStP7pjZN0E9HWUfgJXw@public.gmane.org>" @subject = "[Chronos] Weekly report"...
2008 May 27
6
case...when statement bug when using openid_authentication?
...dentity_url(identity_url) assign_registration_attributes!(registration) if current_user.save successful_login else failed_login "Your OpenID profile registration failed: " + @current_user.errors.full_messages.to_sentence end else failed_login "Sorry, no user by that identity URL exists" end else logger.debug "Something other ..." end end end If you look at the logger.debug calls, you''ll see that when we get...