similar to: creating variables on the fly with a loop

Displaying 20 results from an estimated 20000 matches similar to: "creating variables on the fly with a loop"

2006 May 08
2
Queries with has_and_belongs_to_many relationship
I was able to create a has_and_belongs_to_many relationship for my app, but now I''m not too sure how to write queries for it. Basically, I have a table ''courses'' that has_and_belongs_to_many ''categories'' and vice versa So I''m trying to figure out how I would find only the courses that belong to a category that I specify. Let''s
2009 Dec 07
1
Cucumber and general Ruby question
Hello, I have this cucumber step definition: Given /^the site has pages "(.+)" and "(.+)"$/ do | page_1, page_2 | Page.create :title => page_1 if Page.find_by_title(page_1).nil? Page.create :title => page_2 if Page.find_by_title(page_2).nil? end This works, but obviously I would like to DRY it up. I was thinking along the lines. Given /^the site has pages
2009 Jan 31
0
save after delete returns true but actually fails
Hi, I''m using Rails 2.2.2. I noticed that creating two references to the same database ActiveRecord object, then deleting with one of them, followed by saving with the other, true is returned, but no new record is actually saved. e.g.: doc=Document.new(:title => "sam''s speciality") doc.save doc.id # ==> 23 doc2=Document.find_by_title("sam''s
2016 Apr 26
0
Antwort: Fw: Re: Creating variables on the fly (SOLVED)
Hi Don, Hi to all readers, many thanks for all your answers and all your help. I adapted Don's code to my data and Don's code does the trick: str(Kunden01) for (year in 2011:2015) { Reeller_Kunde <- paste0("Reeller_Kunde_", year) Umsatz <- paste0("Umsatz_", year) cat('Creating', Reeller_Kunde,'from', Umsatz,'\n') Kunden01[[
2007 Oct 05
7
Easy AR association stubbing
I''ve added a method to the mock class that makes it pretty easy to stub associations in rails. I''ve been using it for awhile and it seems to cut down on a lot of setup code for the controller and model specs that use associations. #before @person = mock_model(Person) posts = mock(''post_proxy'') posts.stub!(:build).and_return(mock_model(Post, :save => true))
2016 Apr 22
4
Creating variables on the fly
Hi all, I would like to use a loop for tasks that occurs repeatedly: # Groups # Umsatz <= 0: 1 (NICHT kaufend) # Umsatz > 0: 2 (kaufend) for (year in c("2011", "2012", "2013", "2014", "2015")) { paste0("Kunden$Kunde_real_", year) <- (paste0("Kunden$Umsatz_", year) <= 0) * 1 +
2005 Dec 28
1
making has_and_belongs_to_many save more elegant
When a user creates a post I also want to save all the tags associated with it. I do that in the post_controller like this presently: def save @post = Post.new(@params[:post]) @tags = Tag.new(@params[:tags]) @post.user_id = session[:id] if @post.save @tags.title.split('','').each do |tag| present_tag = Tag.find_by_title(tag.strip) present_tag =
2013 Jan 28
0
[LLVMdev] [PATCH] parallel loop awareness to the LoopVectorizer
On 01/28/2013 06:51 PM, Hal Finkel wrote: > Is this sufficient to implement #pragma ivdep in clang? I'm not completely sure of this: "Note: The proven dependencies that prevent vectorization are not ignored, only assumed dependencies are ignored."
2007 May 15
1
zisofs-tools sloppy option does not work
This isn't a syslinux issue, but I don't see a mailing list setup for the zisofs tools. Forgive me if this is sent to the wrong place. The sloppy option does not work as documented in the mkzftree man page. Here is the patch I used to enable it. --- zisofs-tools-1.0.7/mkzftree.c.sloppy 2007-05-15 08:42:20.000000000 -0400 +++ zisofs-tools-1.0.7/mkzftree.c 2007-05-15
2013 Jan 28
0
[LLVMdev] parallel loop awareness to the LoopVectorizer
About these disclaimers associated with ivdep and such... You guys are overthinking it. They're just saying you cannot force the compiler to vectorize or parallelize a loop that it knows (can prove!) is not a parallel loop. They are not obliging the compiler to do dependence analysis or alias analysis or anything. For example len = 0; while (A[i]) { i++; len++; } Assert all you want;
2008 Apr 07
5
Associations errors
undefined method `each'' for 0:Fixnum at line @school = School.find_by_title(params[:school_id].gsub(''-'', " ")) for team in @school.teams ........ end @school does exist cause i tried with .find(:first) and it gave the same error. Also I''m getting undefined method `reject'' for #<Game:0x24ca1c4> From @home.game_ids = @game
2009 Jan 08
3
Ashlee Vance's article on R in the New York Times
Ashlee Vance's article on R in the New York Times. This is typical of the New York Times. Because they get to coast on the prestige and reputation of their brand , they have a history of just this sort of journalistic sloppiness. Whether it's the author or the editor at fault doesn't really matter, they do this screw-up all the time. Look, if you write an article on the first page of
2001 Jun 10
1
documentation and \sloppy (PR#976)
Hi When preparing documentation using Rd2dvi sometimes we get "overflow" on some lines. The consequence is that in the documentation there are some lines where words are not hyphenated or moved. The final document has some lines with more columns than the rest of the text. This happens when we use \code{} (which probably calls the \tt in latex). I've been checking the documentation
2004 Jun 03
3
Sloppy argument checking for named arguments
Christian -- This is not a bug, but a feature, and the dot is not the issue here. R uses partial argument matching on function arguments. So: > f <- function(foobar = 0){print(foobar)} > f function(foobar = 0){print(foobar)} > > f(fo=1) [1] 1 > f(foo=1) [1] 1 > f(foob=1) [1] 1 > f(fooba=1) [1] 1 > f(foon=1) Error in f(foon = 1) : unused argument(s) (foon ...)
2006 Jan 20
2
Creating thumbnail on the fly
I was doing some research about creating thumbnail images on the fly after an image has been uploaded in a form, but for some reason it''s not working for me. I''ve downloaded ImageMagick 6.2.5 for Mac but when I run a test (identify image.gif) it gives me this error: dyld: Library not loaded: /sw/lib/libjpeg.62.dylib Referenced from: /Developer/ImageMagick-6.2.5/bin/identify
2005 Dec 15
0
Creating and managing Rails routes on the fly
Here is what I''d like to be able to do: I want to be able administer routes using a rails application. So an interface would list routes and give users the ability to manage these on the fly: class RoutesController < ApplicationController # very simple example def add ... Routes.connect ''customurl'', :controller => "customcontroller",
2006 Jan 26
3
Using variables within a string - The function doesn''t pass the value?
Hello everyone, As a beginner to ROR, I am very confused regarding why the following is happening. If my function is defined as def self.home_categories (portal_id) find(:all, :conditions => [ "portal_id=?", portal_id ] ) end the following doesn''t works (the database is queried with a value of 0. portal_id=1 @categories =
2009 Mar 21
2
Creating dataframe names on the fly?
I am aware that it is easily possible to create var names on the fly. e.g. assign(paste("m",i,sep=""),j) but is it possible to assign dataframes to variables created on the fly? e.g. If I have a dataframe called master and I wanted to subset parts of those data into separate dataframes, I could do: m1=subset(master,master$SAMPLE=='1')
2018 May 23
0
Creating users on the fly, for testing?
I'm trying to set up a reproducible test environment for a MUA I'm working on, with accounts and dummy data that can be trashed and restored while testing. I'd like to exercise the IMAP client part of the MUA, and am looking into using a local dovecot instance to do that. I'm trying to make this as minimal-config as possible: ideally the test environment could create a dummy
2010 Nov 01
2
Creating RESTful helpers on the fly
If I have a resource called ''assets'' then I get for free a bunch of helpers, like assets_path new_asset_path and so forth, right? I would like to be able to create a call to one of these on the fly when I only find out the name of the resource at run time. For example I would like to do this: resource_name = "assets" resource_path(resource_name, method => :new)