similar to: Quick question: Iterate through a collection - no duplicates

Displaying 20 results from an estimated 9000 matches similar to: "Quick question: Iterate through a collection - no duplicates"

2006 Mar 22
3
Which JavaScript effect is this?
http://canadaonrails.com/ (when you hover over news and events) I''ve seen this implemented on a few rails sites now and I was just wondering if it is just a simple javascript from the prototype library. Does anybody know of any links on how to do this? Thanks in advance! -- Posted via http://www.ruby-forum.com/.
2006 Jun 01
7
Active Record Basics - Making it commentable
hi everyone, I hope someone can help me out with some active record basics? I''ve been banging my head for the past 4 hours and I can''t seem to get it to work. I am trying to add comments to a caption (just like how one adds a comment to a post in a blog). I seem to be able to read posts just fine from the DB, however, I can''t use the "recordComment"
2006 Jun 17
1
Quick Question: Random item from array
Well I think this is a quick question. I would like to select a random item from an array. I''m thinking maybe I need to generate a random number from 0 to array length. Actually I''m not exactly sure how to do this since I can''t seem to find math.random/math.floor on ruby api? Knowing ruby, there is probably a much easier way to do what I am trying to do. Any
2006 Jun 03
6
Calculating row COUNTs
hi everyone, I''m trying to do a simple calculation in my rails project. I would like to find all rows in a table that match the given id of another table (ie. comment_id) and has the value = 1 ("value" is a field in the table), then add those values up. Next find the same rows with the value = -1 and add those values up also. Finally, I would like to find the total.
2005 Dec 18
2
Could someone host my 1mb rails app??
Hi Everyone, Would someone be able to do a huge favor for me and host a very small 1mb rails app for me?? I can''t get my hosting up and running yet and I really need it up and running by today for my professor to check it off. I only need it up for about two weeks. You will get a lot of karma points for it :) Thanks in advance!! Jordan -- Posted via http://www.ruby-forum.com/.
2006 May 29
3
Timer for executing events
Hi Everyone, I hope you guys can help me out. What is the best way to go about using a timer to execute events? I would like to execute a block of code every 24 hours (or at midnight - server time). Is this possible? What I am trying to get at is that I would like to create a new page every 24 hours and have that serve as my front page. Is it possible to route to this ''new
2006 Jun 08
5
Displaying Calculation on Index
Hi, I am trying to create a simple point system and display the total on my index page. So I have my db basically setup like this: Posts id, body, created_at, user_id Post_points id, post_id, user_id, created_at, value So as you can see I am allowing other users to create points on the post and my db will store who gave the point as well. "value" is the point value which can
2011 Aug 17
1
has_many :through, collection<<(object) and duplicates.
Hi, I''m facing a strange behavior in Rails with the has_many association and the generated collection<<(object, ...) method that comes along. I''ve got an Object model and a Tag model, plus a taggings table to join the two together. On Object, I set these associations: has_many :taggings, :as => :taggable, :dependent => :destroy has_many :tags,
2005 Dec 18
5
restarting fastCGI process
Hi, I am very new to this so please go easy on me... I am trying to deploy my app on dreamhost and I seem to be having problems getting it working. One of the troubleshooting items on the wiki states: Rails apps in production mode do not reflect changes made after they start running. So, if you found a bug, fixed it and nothing appeared to happen--this is probably because you
2007 Jan 05
4
Fast Removing Duplicates from Every Column
Hi, I'm looking for some lines of code that does the following: I have a dataframe with 160 Columns and a number of rows (max 30): Col1 Col2 Col3 ... Col 159 Col 160 Row 1 0 0 LD ... 0 VD Row 2 HD 0 0 0 MD Row 3 0 HD HD 0 LD Row 4 LD HD HD 0 LD ... ... LastRow HD HD LD 0 MD Now I want a dataframe that looks like this. As you see
2005 Dec 16
13
How to pass a collection to paginate?
There must be a better way to write this code: @project_pages, @projects= paginate :project, :per_page => 10, :conditions => ["account_id = ?", account] ?! If only I could pass the sub-collection account = ... @projects = account.project to paginate, instead of letting it extract it with a find :all + sql conditions Alain. -- Posted via
2008 Aug 31
9
assigning collection values and exceptions
hi everyone, I''ve this code in my Report model: has_many :report_reasons, :validate => true has_many :reasons, :through => :report_reasons #, :uniq => true # :accessible => true def reason_attributes=(reason_attributes) reasons.clear reason_attributes.uniq.each do |reason| reasons << Reason.find_or_create_by_content(reason) end end
2012 Feb 02
1
Quick bash tip for finding free SIP extensions from your sip.conf
Created this function on one of my machines today, thought others might find it useful: freesip() { comm -2 <(seq $2 $3) <(cat $1 | grep ^\\[ | sort | uniq | tr -d \[ | tr -d \]) | grep ^[[:digit:]] } On RedHat/CentOS based systems you can create the following file to have the function available on login: /etc/profile.d/freesip.sh # Free SIP extensions freesip() { comm -2 <(seq $2
2006 Jun 19
2
finding duplicates in an array
an application i am working on sends emails to an array of users. it is possible for the user''s email to actually be in the array more than once. i don''t have a real strong grasp of the ruby syntax yet, but is there an easy way to go through and either remove all of the duplicates or at least only send an email to that user once? -- Posted via http://www.ruby-forum.com/.
2006 Mar 28
5
Anyone use .uniq! ???
could anyone by chance give me a working example of the .uniq! method? i''ve been trying all day. any help would be much appreciated! jon -- Posted via http://www.ruby-forum.com/.
2006 Jan 21
1
Sortable Element with Partials?
Hi Everyone, I posted this last month and unfortunately, I didn''t recieve any replies. Maybe this time I''ll have better luck. I originally had my sortable element list working properly like so: <ul id="sortable_list"> <% @items.each do |item| %> <li id="item_<%= item.id %>"><%= image_tag "dragme.gif"
2006 Dec 05
4
has_many with :uniq not working for me
Hi all, I have a relationship (no really!) class RiskMatrix < ActiveRecord::Base has_many :severities, :order => :position, :uniq => true end class RiskFactor < ActiveRecord::Base belongs_to :risk_matrix validates_presence_of :descriptor, :example validates_uniqueness_of :descriptor, :example, :scope=> :risk_matrix_id end class Severity < RiskFactor
2006 Feb 07
1
habtm :uniq causing duplicate inserts? How to update Rails?
Hello *Gem* experts, Sorry for asking multiple questions in one post but they are both related to one problem. So far I have the following code: class Member < ActiveRecord::Base has_and_belongs_to_many :blogs, :uniq=>true ..... end class Blog < ActiveRecord::Base has_and_belongs_to_many :members, :uniq=>true ... end The issue is that
2006 Aug 11
1
Avoiding adding duplicates to has_many collection?
Since there''s no ''exists?'' method for a has_many collection, is there an easier way to avoid adding duplicates to a collection? (I assume obj.items << item would add duplicates if repeatedly called.) Right now I do: category = Category.find_or_create_by_name(category_name) directory.categories << [ category ] if directory.categories.find(:first,
2008 May 28
2
Re: calculating the needed swiotlb in dom0
I just found out that setting swiotlb=128 in dom0 grub.conf allowed me to run my mythtv domU with additonal options to ivtv: in /etc/modprobe.d/options options ivtv enc_mpg_buffers=8 Setting this to any higher value causes a kernel panic. I want to be able to specify options ivtv enc_mpg_buffers=16 enc_vbi_buffers=8 How much swiotlb do I need? Is there a way to figure this out or is it just