search for: my_column

Displaying 5 results from an estimated 5 matches for "my_column".

2008 Feb 01
5
ActiveRecord - find
Hi- What I would like to do is select a single column out of my model, say the column is called my_column, and store the result in an array, which it should be, right? For example, if I do: @my_arr = Model.find(:all, :select => "my_column") This should fill @my_arr with all the values from "my_column", right? So then I can access the data by some_other_variable = @my_arr[0], o...
2011 Jun 15
2
Count occurances in integers (or strings)
Hi, I have a dataframe column from which I want to calculate the number of 1's in each entry. Some column values could, for example, be "0001001000" and "11110000111". To get the number of occurrences from a string I use this: sum(unlist(strsplit(mydata[,"my_column"], "")) == "1") However, as my data is not in string form.. How do I convert it? l tried: lapply(mydata[,"my_column"],toString) but I do not seem to get it right (or at least I do not understand the output format). Also, are there other options? Can I easily ca...
2011 Sep 12
0
Migrate column from text to binary (PostgreSQL)
Hello, So I''ve realized one of the columns in a table has to be binary instead of text. However, a straightforward change_column :my_table, :my_column, :binary fails under PostgreSQL (9.x series) The error message being: PGError: ERROR: column "my_column" cannot be cast to type bytea : ALTER TABLE "my_table" ALTER COLUMN "my_column" TYPE bytea Now I''ve being told this problem can be solved with USING cl...
2008 Nov 03
17
SQL queries in Rails
Hi... I want to know the equivalent instructions to insert, update, search and delete a registry. I know Rails can do it easily Thanks to ActiveRecord, but here''s the catch: I''m using PostgreSQL. As I''m using SQL to do the migration (Including the foreign keys), I need to know if I can use SQL queries to do those actions. Is there an example out there? I uncommented
2005 Nov 03
9
[Idea] session-wide persistent variables
I was thinking about having instance variable stored and fetched from session container automatically before calling an action and after the action is finished. Using methodology of accessors it would look like: class MyController < ActionController::Base persistent_attr :person def alfa person = ''John Smith'' # render as usual view alfa.rhtml with anchor