similar to: Adding methods to model based on foreign table rows

Displaying 20 results from an estimated 200 matches similar to: "Adding methods to model based on foreign table rows"

2005 Dec 22
1
How to write unit tests with respect to model callbacks?
Hello, I am exploring the "Testing" part of Rails, but It seems some things work differently than I thought it would. Consider the following model: class Client < ActiveRecord::Base has_one :project def after_create Project.new(:name => self.name, :is_client => true, :client_id => self.id).save end def after_update
2006 May 22
3
STI, HABTM & counter_cache
Hello world... I have an interesting issue that the online docs aren''t helping me with. In my app I have 4 models Item < ActiveRecord Deal < Item Product < Item Category < ActiveRecord Item has_and_belongs_to_many :categories... On each category record I''d like to maintain a product_count and deal_count to increase performance. This doesn''t appear
2006 Feb 02
1
tricky form validation
Hi list, I want to create a form validation in my Marketing Model. I want to raise an error only if a previous marketing campaign for a property has not been completed (ie. ended_on IS NULL) I managed to get this working in the Controller using something this: ... if Marketing.count("property_id = #{@marketing.property_id} AND ended_on IS NULL") > 0 ... However I assume
2006 May 22
5
download manager?? anyone?
Hello all, i have been searching for some time now on how to upload files and then display them to be downloaded, haven''t had any luck. it seems all the documentation is for uploading and displaying pictures. is this the same thing? i''m lost... any help would be greatly appreciated. Jon -- Posted via http://www.ruby-forum.com/.
2009 Mar 27
0
consistent segfaults in ROracle with one of the databases
Dear list. Has anybody had any issues with ROracle, namely consistently leading to a segmentation fault? One of our oracle databases seems to have certain issues at the moment (do not know what exactly though) and if that one is queried ROracle definitely fails with a segmentation fault. Any ideas? Here is the trace and below is also a type of query that crashes it: *** caught segfault ***
2005 Nov 02
4
acts_as_metadata?
I''m running into the need (on at least one project now) to implement end-user-customizable "metadata" or properties on model objects. The standard example would be a Person class that had first_name, last_name, etc. but would need to be extended real-time (through the web admin interface) with properties such as phone_number : varchar (30). I''ve done some basic
2020 Jul 16
2
read.csv fails in R console in Ubuntu terminal but works in RStudio after R 3.6.3 upgrade to R 4.0.2
On 7/15/20 1:35 PM, Dirk Eddelbuettel wrote: > On 15 July 2020 at 16:16, Sam H wrote: > | I am trying to download some data using read.csv and it works perfectly in > | RStudio and fails in the R console in the terminal in Ubuntu 18.04 after > | upgrading from R 3.6.3 to 4.0.2. Before upgrading this worked in the R > | console in the terminal also without any issues. > | > |
2004 Aug 06
0
a new directory service
Hello. About your idea, I think that it is important for a radio to "check" multiple styles. I'm planning to cast a couple or 3 of stations that are _not_ monographic and will be "sports" from x to y hours, "pop" from y to z hours, "talk" from z to p hours and so on. That is because people that are listening the same genre for hours want to change. Why
2006 Jan 09
0
Saving or updating multiple models
Hello all, I was wondering how one would create multiple models in one controller action. Consider the following models: class Worker < ActiveRecord::Base belongs_to :person belongs_to :user validates_presence_of :person_id end class Person < ActiveRecord::Base has_many :workers end class Client < ActiveRecord::Base has_many :workers end class User <
2005 Dec 27
1
SOAP + HTTP authentication
Hey, Just had a question. Been pulling out my hair all weekend trying to get SOAP to work properly in Rails and even straight on Ruby. I started with Rails'' AWS and moved to Ruby''s internal libraries, after which I tried out SOAP4R. Now, my question is, does Rails or even Ruby itself support SOAP client calls through basic HTTP Authentication? From the research I''ve
2010 Sep 19
2
can't get write_sectors to work...
Hi, Hopefully you someone can tell me what I'm doing wrong. First, the code. I placed this at the bottom of the main loop in com32/modules/disk.c as a simple test of writing to the disk: printf(" Host bus: %s, Interface type: %s\n\n", d->edd_params.host_bus_type, d->edd_params.interface_type); zero_buf = calloc(1, d->edd_params.bytes_per_sector); for(int
2006 Jun 08
2
counter_cache is not looking for children_count with acts_as_tree
Hi there, the acts_as_tree API says that I can set a counter cache and that it will automatically increment the "children_count" column. I did that but when I create a new page it asks for a "pages_count" column instead. Here is the relevant part of page.rb model: class Page < ActiveRecord::Base acts_as_tree :order => :position, :counter_cache => true
2008 Apr 14
4
Unable to load module chan_zap.so
I am having trouble with chan_zap.so not loading. When I load it from modules.conf, Asterisk bails out without any error message. When I load it from the console, it just says "Unable to load module chan_zap.so" no matter what verbose level I am using. dmesg says: Zaptel Version: 1.4.4 Zaptel Echo Canceller: MG2 Freshmaker version: 73 Freshmaker passed register test Module 0:
2006 Mar 10
5
case insensitive search
I am having trouble with a simple gallery search. I type in a segment of the address and i only seem to be getting results if I use the correct case. This is in my Gallery controller: def search @gallery = Gallery.find(:all, :include => :property, :conditions => "address LIKE ''%#{@params[:keywords]}%''") end On a different note: I am having
2006 Feb 08
5
beginner - problem with understanding relationships
Hi folks, I''m new to this... so hopefully someone can help me. I have a few objects... Property and Address and Landlord... where a Property has an address and a landlord has an address also. I''ve modelled this in the db with the properties table having an address_id and the landlord table having an address id. My rb looks like: class Property < ActiveRecord::Base
2009 Mar 01
1
Strange behavior of Source.column_names
I have a class named Source and a controller named SourceController etc. When I use Source.column_names in the view all names except names ending in _id is listed, although according to the documentation all names should be listed When I use Source.column_names in the source controller it lists correctly all names also the ones ending in id. When I first call Source.column_names in the
2003 Mar 18
6
bitstream changes
ok now I see why we need another packet in the header. The first one is basically for ID purposes (theora_decode_header()). I've jammed my huffman trees in there but it sucks because I need them later on when I actually build the huffman tree structs (theora_decode_init, calls InitHuffmanSet()). At that point the original header packet is gone so I've been keeping it around in a buffer.
2006 May 08
0
ActiveRecord and refreshing column info
Let''s say I want to find out what column names exist in two tables, table_a and table_b. One way I''ve been doing this is using ActiveRecord and the column info it returns. After establishing a connection for ActiveRecord, I do the following: ActiveRecord::Base.set_table_name("table_a") column_names_a = ActiveRecord::Base.column_names
2009 Feb 25
1
Problem with set_table_name
Dear friends, I ran the following in my console.Assume I already have the postgresql connection . >> class D < ActiveRecord::Base >> end => nil >> D.set_table_name "users" => nil >> D.column_names => ["id", "name", "fname", "lname", "password", "addr1", "addr2",
2006 Jan 11
0
Connection problem with a generic-runtime-built ActiveRecord::Base
Hi, I''m trying to create a "runtime-generic" ActiveRecord class, It means I don''t need to know the table or database, before I create my program ruby-rails. So I don''t need to predefine my database in environment.yml file and pre-build classes inherited from ActiveRecord::Base. I write some code, it seems to work. However, I can''t disconnect my