search for: in_groups_of

Displaying 19 results from an estimated 19 matches for "in_groups_of".

2008 Jan 01
7
in_vertical_groups_of
Hi all, Here''s another contribution for anyone interested. In Railscast episode 28, Ryan Bates showed us in_groups_of which allows you to group array members such as >> list = [1, 2, 3, 4, 5, 6, 7] => [1, 2, 3, 4, 5, 6, 7] >> list.in_groups_of(3) => [[1, 2, 3], [4, 5, 6], [7, nil, nil]] This allows you to iterate over the groups and, for example, display a list of things in a tabular form...
2006 May 31
7
Getting 22 elements
Hello, I''ve done === class HomeController < ApplicationController def index @country = Country.find(:all, :include => "cities") end end === And rhtml is: === <% @country.each do |country| %> <h1><%= country.name %></h1> <% country.cities.each do |city| %> - <%= link_to city.name, :action =>
2006 Sep 01
0
Are you using Array#in_groups_of(n, false)?
Are you using Array#in_groups_of(n, false)? That is, you want the array chopped into n groups, and if its an uneven number, you want the missing positions filled with "false". If so, please post the brief snippet where it is being used. (I''m trying to settle a bet with Mr. koz.) -- David Heinemeier Hansson htt...
2009 Mar 08
1
Working with in_groups_of
I''m trying to build a table out using in groups of, but I''d also like to be able to customize the first and last rows. Apart from the actual formatting, is there an efficient way to figure out how many total groups there are and what group the iteration is in? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this
2010 Apr 30
0
using in_groups_of to get data to display horizontally
Hey all, The following has two columns. Each column has a head with a name and then a data cell with a time directly below it. I''m wondering how I can get the time to display next to the name, not below it. - @clock.in_groups_of(2) do |group| %tr.header - group.each do |item| %th= item.name %tr - group.each do |item| %td %span.value{"offset" => item.zone.now.utc_offset} = item.zone.now.to_s(:us_short_time) Thanks for any response. -- Posted via http:/...
2006 Jul 20
11
3 columns
Hi all, Not really sure what to put in the title so hope people still open this! What I want to do is produce something like this Col1 Col2 Col3 data1 data2 data3 data4 data5 data6 data7 data8 data9 data.. data.. data.. data.. data.. data.. data-n data-n+1 data-n+2 I can get the data back from my db
2009 May 27
4
Scaffolding Results Format
Hi Everyone, I built a scaffold and I''m having trouble getting results properly formatted. (I need to get the data into multiple columns instead of just one big column) I can''t get all of my CSS to work properly in scaffold.css, layout/books.rhtml, or the books/index.rhtml.erb Anyways, maybe you have a suggestion. Default view (127.0.0.1:3000/books) Title Abstract
2006 Apr 09
6
Write/Display AR query as Grouped Results?
I''ve got a publications table that contains an author_id foreign key and a pubrole_id foreign key. What I want to do is query the DB using AR so that I can get a list of all publications that belong_to a particular author, and group the results by the pubrole.role_name (Author, Joint Author, Editor, etc.) so that the results look something like: Author book1 info book2 info etc.
2006 Jul 19
1
Displaying data in a table
I''m trying to display a series of pictures in a table. Rather than just house each of the pictures in separate rows, I''d like to have 5 pictures per row. So, basically after I iterate through five columns in my table, I need to start a new row and show the next 5 pictures. Could someone help me with the looping structure I''d need to create to do this? Thank you! Sarah
2006 May 03
2
grouped output
hello, Suppose I have a table that looks like this: center name email Health Jon jon@test.com Health Bob bob@test.com Admin Jane jan@test.com Admin Jill jill@test.com I would like the output to look like this: Health Jon jon@test.com Bob bob@test.com Admin Jane jan@test.com Jill jill@test.com when i using cold fusion, this was easy via a tag called cfoutput. when i was using java, this was
2010 Oct 15
3
Noughts and Crosses layout with a variable number of entries
I have a product listing of 9 per-page. The products on the far right and bottom row should NOT have a border on the aforementioned sides. So, similar to a noughts and crosses layout. However, pages do not always have 9 products to display. You may have a better understanding if you see the code I''m currently using: http://pastie.org/1223260 The code above is passed inside a block and
2008 Aug 25
21
How much test data to use in specs
I''m not sure how much test data I should be using in my specs. I''m writing specs for the Property model in my Rails app. Its "address" attribute is going to be validated with this regex: /\A\d+[a-z]? [-'', a-z]{2,128}\Z/i At the moment, my plan is to spec out the following possibilities. A property is invalid if its address: 1) doesn''t begin with
2006 Aug 11
1
Group By
Hi, I have a table similar structure below. id name position page 1 name1 1 1 2 name2 2 1 3 name3 3 1 4 name4 1 1 5 name5 1 1 6 name6 1 2 What i want is to select all the items for a given page number grouped by pos and displayed in a view using a loop like: display position number, number of records for
2009 Nov 08
1
link_to_remote with image_tag using Paperclip
...5", :thumb => "80x70"} In my Front controller: def index @photos = Photo.find(:all) @photos = Photo.paginate :per_page => 28, :page => params[:page] end In index.dryml: <% outer = ''a'' %> <% inner = 1 %> <% @photos.in_groups_of(7).each do |photorow| %> <div id="<%= outer %>"> <% photorow.each do |photo| %> <div id="<%= inner %>"> <% link_to_remote (image_tag(photo.mainimg.url(:thumb)), :url => {:action => ''projects/...
2009 Jul 08
2
RuntimeError (JPEG marker not found!):
Hi, while generating the PDF file , i am getting following error.. please help for me. RuntimeError (JPEG marker not found!): C:/Ruby/lib/ruby/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ graphics/imageinfo.rb:176:in ` measure_JPEG'' C:/Ruby/lib/ruby/gems/1.8/gems/pdf-writer-1.1.8/lib/pdf/writer/ graphics/imageinfo.rb:174:in ` loop''
2006 Apr 25
6
SQL WHERE equivalent in rails
What is the equivalent of the WHERE SQL condition in rails? I''m thinkin this could be something like: <% for product in @products where category="1" %> but obviously the syntax is wrong. -- Posted via http://www.ruby-forum.com/.
2009 Mar 27
1
using pagination to group pages by attribute value
Hi - I''m trying to group records based on some attribute they or an association of their''s have. The simplest example I could think of to drive my point is this: Assume the following model associations (pardon my butchering of rails) - Faculty has_many :courses Course belongs_to :faculty I want to paginate courses based on the name of the faculty they belong to. The paging
2006 Aug 11
2
Array#chunk method, maybe someone will find this useful
class Array # break an array up into <size> chunks def chunk(size=1) return self if self.empty? raise ArgumentError if !size.kind_of? Integer y = self.length.divmod(size) rows = (y[1] > 0) ? y[0] + 1 : y[0] arr = Array.new(rows) (0...rows).each do |i| arr[i] = self.slice(size*i, size) end (arr.last.length...size).each { |i| arr.last[i] = nil }
2008 Apr 24
7
Please help. The error occurred while evaluating nil.name
Okay so heres my code which works fine, i''ll explain the problem below. <% for num in 1..-04Gazou6+pmm/bHYDwDEOA@public.gmane.org %> <table class="products" id="table1" cellspacing="2" cellpadding="3" border="3"> <tr> <td> <table width="25%"> <tr> <tr> <td><%=