similar to: Setting up a column alias in ActiveRecord object

Displaying 20 results from an estimated 10000 matches similar to: "Setting up a column alias in ActiveRecord object"

2006 Jul 03
4
text_field doesn''t call overridden ActiveRecord getters
All, In a template, I have <%= text_field :target_list, :DateReceived, { :title => ''uploaded_at'', :class => ''target_list_info'', :disabled => ''true'' } %> Here is the DateReceived method on my
2006 Jul 14
1
Weird validation problem
I have a field called Fax in my model. I store it as a 10-digit number with no other characters but I display it as a nicely formatted phone number. I have a validation on it like this: validates_format_of :Fax, :message => ''number should be formatted using (XXX) XXX-XXXX'', :with => /^\(\d{3}\)\ ?\d{3}-\d{4}$/ If I put 1234567890 (10 digits) in my field, the
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2006 Mar 14
5
Column aliasing in ActiveRecord?
Anybody know of a way to alias a column in ActiveRecord such that you could reference it via a different symbol in your view for view purposes? Like my column is named X but I want to display it as Y and maybe I have an accessor named Y set up on the model so that when I "call" Y from the view (and controller?) I''m actually manipulating the column X? Hope that makes sense.
2006 Jul 05
7
HABTM join table has an "ID" column - is this an issue?
All, I''m building model objects for existing tables that I cannot modify. In AWDWR, Dave says "Note that our join table has no id column...The second reason for not including an id column in the join table is that AR automatically includes all columns from the join tables when accessing rows using it. If the join table included a column called id, its id would overwrite the id
2010 Aug 13
1
RDCOMClient interface - problems setting a variable
I try to produce and modify shapes in a PowerPoint presentation but run into a difficulty setting a variable. library(RDCOMClient) # load RDCOMClient package library(SWinTypeLibs) # package SWinTypeLibs from Omegahat to access information about COM libraries ppt = COMCreate("PowerPoint.Application") # create a ppt COM ppt[["Visible"]] <- TRUE # set COM
2006 Jul 14
7
Form validation - keepin correct fields displayed on refresh
All, I''m finally doing my first real form in Rails - the model object that I''m entering information for has 8 validations so far. If I type in good values for all the fields but one, I get the pretty validation, and the nice field highlighting, but all of the fields are cleared, forcing me to retype all of that info. That is a big drag. Is there a standard way to get the
2009 Mar 15
0
Assigning to factor[[i]]
I am a bit confused about the semantics of classes, [, and [[. For at least some important built-in classes (factors and dates), both the getter and the setter methods of [ operate on the class, but though the getter method of [[ operates on the class, the setter method operates on the underlying vector. Is this behavior documented? (I haven't found any documentation of it.) Is it
2006 Mar 20
5
Wrap error_messages_for() call when no instance var present
I am trying to put some smarts around a call to <%= error_messages_for %> so that when I first come into this page i.e. when my instance variable @target_list has not been defined yet, the page doesn''t break. I''m doing this: <% if @target_list? %> <%= error_messages_for ''target_list'' %> <% end %> I get a syntax error on line 1.
2012 Sep 09
2
mattr_accessor inside a class
Rails extends Ruby with mattr_accessor (Module accessor). As Ruby''s attr_accessor generates getter/setter methods for instances, mattr_accessor provide getter/setter methods at the module level. In below example, you see that mattr_accessor declared in the class context of LookupContext. It''s declared in class, not module. However, modules are defined in LookupContext, for
2006 Apr 03
4
Multiple file uploads - only one file object gets posted
All, Trying to upload multiple files. Form: <% index = 0 for @image in images do %> <TR> <TD> <%= @image.path.split(''/'').last[0..39] %>: <% if ((! @image.path.nil?) && (@image.path.length > 40)) %> <%= h("...") %> <% end %> </TD> <TD> <%=
2006 Mar 20
8
Best way to organize non-controller logic???
I don''t want to put certain code in my controller because I think it makes things more confusing. What is the best way to manage business logic such that it doesn''t end up in the controller? Basically, where should I put my regular utility classes and backing objects that may not be models? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Mar 20
4
Ajax.Request w/standard redirect doesn''t render
I am doing an Ajax call in my page to a controller method like so: new Ajax.Request(''<%= url_for(:action => "target_list_add" )%>'', { asynchronous:true });" In my controller method "target_list_add", I do something and then I say: redirect_to( :action => ''target_list_upload'', :layout => false ) I know for certain
2006 May 25
5
rake migrate VERSION=0 doesn''t appear to execute
All, I''ve decided to jump into Migrations before I get too far along on the DB side of things. I already have some tables built, and I went ahead and built the migration that would have created them from scratch, and I made sure that there was a self.down section to drop them. I wanted to verify that I could roll back so I figured I would use rake to drop these pre-existing tables
2006 Jul 17
18
Inserting datetime value into SQL Server
I have a SQL Server column named StartTime of (SQL Server) type datetime If I attempt to set the attribute using public def StartTime=(time) write_attribute(:StartTime, "{ts ''1899-12-30 #{time.hour}:#{time.min}:#{time.sec}''}") end it''s inserting a NULL value. Anyone else able to successfully insert a date time value into a SQL Server table using
2014 Mar 05
2
[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
This rule does not seem to be widely followed by Clang today. Looking at Parser and Sema, many getters (0 argument functions with names matching /^get[A-Z]/) return mutable references to long-lived objects. Looking through Decl.h, things are a little different: we rarely return references, but do frequently return pointers that provide mutable access to contained objects. On Tue, Mar 4, 2014 at
2008 Nov 06
3
Verifying some understanding about manipulating DB data in before/after callbacks in RSpec
We had an after(:each) callback that looked like this: PurchaseOrder.find(:all).each {|po| DraftInvoice.find_all_by_po_number(po.po_number).each {|di| di.destroy}} which we were hoping would reset some purchase order data in a certain way. However, because we have "self.use_transactional_fixtures = true" set in test_helper.rb, this code was never getting committed. So, I just
2006 Jun 22
4
ADVICE: Generating unique identifiers for later DB insertion
All, I have an ActiveRecord object that I need to be able to uniquely identify _before_ I actually save the object (I may not end up saving the object based on conditions). This is because I want to use the ID in another context (a file name in the filesystem). Depending on conditions, I may or may not need to do a lot of stuff between the time that I generate the object ID and actually
2008 May 18
4
[LLVMdev] Opaque type usage to represent foreign types
In my project I have a group of foreign types (C++ classes) that I want to use, but don't want to represent as structs within LLVM. For example, for each field in each C++ class I have a setter and getter function that I'd like to use. The setters and getters are "extern C" functions to avoid problems with C++'s name mangling. After going over the documentation it
2020 Sep 07
0
Re: [libnbd PATCH 0/3] Improve type-safety of ocaml/golang getters
On Sat, Sep 05, 2020 at 08:40:57PM -0500, Eric Blake wrote: > Natural fallout after my recent testsuite additions that fixed a > couple of ocaml bugs in the setters. However, on at least the OCaml > code, I'm not sure what we should do if a newer libnbd ever returns a > bit that an older NBD.mli was not expecting at the time the OCaml > compiler ran (see below). I'm also