similar to: Database abstraction

Displaying 20 results from an estimated 300 matches similar to: "Database abstraction"

2011 Apr 18
1
has a field through an association
Hey guys, Trying to figure out how to do something like the following: class Child belongs_to :parent has_field :some_field, :through => :parent end class Parent has_one :child attr_accessible :some_field end child.some_field #=> parent.some_field child.some_field = value #=> sets parent.some_field = value I can of course accomplish this by adding custom accessors
2006 May 10
3
migrations :timestamp becomes :datetime in mySql
For some reason whenever I try and create a timestamp column with migrations and mysql I get a datetime column instead. That''s kind of annoying because I want the column to update every time the row gets changed. Is this a bug, or is there something I can do about it? (Obviously I can manually change my mysql table, but that kind of defeats the point of migrations!) In my migration
2006 Apr 26
5
Best way to split forms into steps?
I have a form with about 30+ fields, which the client is wanting to separate into 3 pages/steps - just wondering what is the best way to go about this, specifically remembering data entered, from one page to another, and making sure the various bits of data are validated correclty, error messages outputted etc etc... is there a best practice method for doing this? -- Posted via
2011 Aug 03
1
Gem and/or meta_where problem
I''ve installed the gem "meta_where" (and it reported back: "Succeeded") but when I use the example in a search method of a controller: Person.where(:some_field.matches => ''%something%'') there is an error that it doesn''t know the method ''matches'', so what still needs to be done to properly activate the gem and make its
2011 Feb 10
3
Finding length of unique numbers in a vector
Hello there, would you please look into my codes? Here I have following: > set.seed(100) > samp <- sample(c(1,-1,0), 20, replace=T); samp [1] 1 1 -1 1 -1 -1 0 -1 -1 1 -1 0 1 -1 0 0 1 -1 -1 0 Here I want to calculate the length of each unique number for above vector. How can I do that? Thanks in advance [[alternative HTML version deleted]]
2011 Mar 10
3
A question about data frame
A very simple question. With a data frame like this: > n = c(2, 3, 5) > s = c("aa", "bb", "cc") > df = data.frame(n, s) I want df$s[1] or df[1,2], but how can I get rid of the extra line in the output about the factor levels: > df$s[1] [1] aa Levels: aa bb cc Thanks, Gang
2008 Apr 02
9
Problem getting the most recent has_many associated object
I can''t get my view to display the most recent parameters from an associated object in a view... here is a birds-eye of my app: I have two models, Ferms and Kinetics. Ferm has_many :kinetics, Kinetic belongs_to :ferm. Kinetic has the fields ferm_id, brix and temp. In my ferms/index view I have a table listing the attributes of each ferm instance. I would like to display the most recent
2011 Mar 09
2
SQLDF - Submitting Queries with R Objects as Columns
Fellow R programmers, I'd like to submit SQLDF statements with R objects as column names. For example, I want to assign "X" to "var1" (var1<-"X") and then refer to "var1" in the SQLDF statement. SQLDF needs to understand that when I reference "var1", it should look for "X" in the dataframe. This is necessary because my SQLDF
2007 Mar 13
13
validates_inclusion_of disabling
Hello all. I have a problem using validates_inclusion_of. I need to switch off some validations during a migration period, is there a way? I tried to use if, with a static method of one of my models, but the behaviour is something strange It seems that the static method should be in a string to be evaluated. And the order of the elements in the if is counting... :if => (:some_field
2008 Aug 27
5
VALIDATION QUESTION
I''m trying to validate a record before save. I''m using one controller in this case furnii where I have all my calls. The problem is that, the form containing the field I''m trying to validate resides in the furnii views. I tried to add validates_presence_of :content (the field name) in both the furnii model and the ratecomment model but it does not work. I know there
2006 Jun 26
3
syntax for observe_field( :with =>
Greetings! What is up with the syntax of this thing? I mean, if the only thing I can send back using :with is the field being observed, then why in the world is the syntax so convoluted? For example, what I''ve been able to get working is: <%= text_field_tag(''date'', illness_date, :size => 30) %></p> <%= observe_field(''date'', :url
2006 Aug 15
2
Unit Testing Problem
I''m having a bit of difficulty when testing my models, I''ve read a few times the testing chapter in Agile web development with rails and at http://manuals.rubyonrails.com/read/chapter/27 but i''m still unsure of what I should be testing. Firstly I''d like to be able to test things like my email validation using lines such as assert User.new(:email =>
2006 Aug 13
5
problems with file_column plugin
1) installation is not as smooth as some other plug-ins. If you follow the instructions on http://www.kanthak.net/opensource/file_column/ it makes a directory called trunk instead of file_column. You have to manually rename it to file_column. I guess this is a minor annoyance but it gives me the feeling that things aren''t quite like other plugins. 2) I get this error: undefined
2005 Aug 10
5
validates_format_of on an optional field using :if
Hi there, I''ve got the following in my model: validates_format_of :postcode, :with => /^([a-zA-Z]{1,2}[0-9]{1,2} [0-9]{1}[a-zA-Z]{2})$/, :message => "is not valid", :if => :postcode ... but it''s not working - it always insists on validation, even if postcode is empty. Basically, the postcode field is optional, but if it''s filled in, I want to
2006 Apr 26
1
How to handle default database values now?
Since interpreting defaults in the database has been ripped out (for PostgreSQL at least), what''s the standard way of specifying defaults now? Right now, I''m doing this: # model def create self.datetime = Time.now super end I hate it. I know there are the ''*_at/on'' automatic fields, but that''ll entail combing through all my code changing
2006 Jun 23
0
help... can''t run ActiveRecord unit tests to test bug fix
I found a bug in ActiveRecord. Being a good netizen, I thought I would write a test to illustrate the bug, fix it, and then submit a patch to the maintainers. However, I can''t run the AR tests. I followed the instructions in RUNNING_UNIT_TESTS but it generates an error immediately /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/test cremes$ ruby -I
2006 Apr 19
0
ResultSetMetaData
dose Ruby or ActiveRecord have the Java/JDBC equivalent for retrieving ResultSet meta data... PreparedStatement statement = null; try { statement = connection.prepareStatement("select * from some_table"); ResultSet rs = null; try { rs = statement.executeQuery(); ResultSetMetaData rsMetaData = rs.getMetaData(); int columnCount = rsMetaData.getColumnCount(); more
2004 Jan 29
0
Destination routing and its implementations?
Hello everyone, I was wondering how i should do destination routing. I now do # ip rule add to x.x.x.x table some_table for each address i need. I was thinking about fwmark option. The problem is that routing decision is made after PREROUTING and not POSTROUTING (name obviously sais that :)) and i need to use -o. In OUTPUT this marking can''t be done. I made this conclusion by studying
2011 Feb 21
1
output selectively change the font
Dear brainy R users, I need to output a matrix, with two colors , meaning some elements using different color I normally use write.table(table.m, file="table file name.csv", sep=","), how could I pass the index for the color ? Many thanks yan ********************************************************************** This email and any files transmitted with it are
2011 Feb 25
2
Compatibility with R for Windows 2.12.2
Hi, Please someone let me know that the installation of both R for Windows 2.12.2 and MS office 2010 on the same system will interfere each other or not. In short, are these two tools compatible to each other? Thanks in advance. Best Regards, Vedajit [[alternative HTML version deleted]]