Displaying 20 results from an estimated 8000 matches similar to: "Building a library system (ActiveRecord question)"
2005 Dec 27
3
Trouble combining :has_many, :finder_sql and :conditions to create a sub-search
I''m sure there''s something right under my nose that I''m missing. I
have two tables with two parallel one-to-many relationships. I wish to
use the :finder_sql parameter to essentially ''or'' the two foreign
keys.
What isn''t working for me is performing a ''sub-search''.
Let''s say the tables are "stores" and
2006 Jan 06
3
Single table inheritance - HowTo?
Hi,
As per another member''s suggestion, I''m trying to user STI. So I have
this table:
CREATE TABLE `settings` (
`id` int(11) unsigned NOT NULL auto_increment,
`type` char(40) NOT NULL default ''General'',
`name` char(40) NOT NULL default '''',
`value` char(128) NOT NULL default '''',
`updated_on` datetime default NULL,
2007 Mar 17
4
Created_on and updated_on in a non-ActiveRecord model
Hi you all,
I have a model simulating an ActiveRecord model, according to the tips
stated in [1]. It is simulated because even though I am gonna save the
attributes in a file, not in a DB, I still want the validations made by
ActiveRecord::Base (see code below).
Well, the thing is that I also want the behaviour of the created_on and
updated_on columns, that get modified automatically before
2006 Apr 13
0
Globalize not with Rails 1.1.2
Does anybody have the latest Globalize (r184) working with Rails 1.1.2?
I can''t seem to get a very simple example to work:
-----
ruby test/unit/news_item_test.rb
Loaded suite test/unit/news_item_test
Started
F.
Finished in 0.10109 seconds.
1) Failure:
test_add_content_translations(NewsItemTest)
[test/unit/news_item_test.rb:49]:
<"US Title"> expected but was
2006 May 16
5
rake aborted! ActiveRecord::ConnectionNotEstablished
Hi all
I''m just learning to use rake and ran into the following problem:
chraftbuech:/Users/Josh/Webwork/CommentingSystem josh$ rake
create_test_news
(in /Users/Josh/Webwork/CommentingSystem)
Create test news
rake aborted!
ActiveRecord::ConnectionNotEstablished
The task''s code is:
desc ''Creates some test news items with comments''
task
2006 Jan 05
3
ActiveRecord setting IDs on auto increment fields
Hi All, I''ve tried to do my searches, but can''t find reference to
this anywhere - My question is about ActiveRecord inserts and IDs. I
have a join table that both the models of the source tables join with
"has_and_belongs_to_many". It seems like ActiveRecord is setting the
"id" field for the join table- This should be an auto_increment and
2010 May 12
16
In development mode not all types are included in the query related to type
class User
end
class Agent < User
end
script/console production
User.find_by_name ''john''
SELECT "people".* FROM "people" WHERE ((("people"."type" = ''User'' OR
"people"."type" = ''Manager'') OR "people"."type" = ''Agent'')) AND
2005 Dec 27
0
How do I combine :finder_sql and :conditions to perform a sub-search on a custom has_many relationship?
I''m sure there''s something right under my nose that I''m missing.
I have two tables with two parallel one-to-many relationships. I wish
to use the :finder_sql parameter to essentially ''or'' the two foreign
keys.
What isn''t working for me is performing a ''sub-search''.
Let''s say the tables are "stores" and
2010 Mar 17
3
Associating a default paperclip image from a different model
Here''s some code, this is my NewsItem model as you can see...
class NewsItem < ActiveRecord::Base
belongs_to :country
has_attached_file :image, :styles => { :original => ''57x57'' },
:default_url => ''/images/football.png''
# has_attached_file :image,
# :styles => { :original => ''57x57'' },
2006 May 05
1
Help with ActiveRecord
Model:
class AdminQueue < ActiveRecord::Base
set_table_name ''adminqueue''
end
Interacting with it in script/console
>> AdminQueue.new
=> #<AdminQueue:0x240a910 @attributes={"topic_id"=>nil,
"resolved"=>nil, "updated_on"=>nil, "action"=>nil, "type"=>nil,
"post_id"=>nil,
2006 Jul 13
5
ActiveRecord inheritance
How to create a super class based on ActiveRecord::Base?
For example:
class ParentRecord < ActiveRecord::Base
end
class ChildRecord < ParentRecord
end
Rails always asks for ''parent_records'' table. Which has absolutely no
need to exist at all. It''s intentionally made as a super class to be
inherited.
Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Feb 02
1
circular table refs in activerecord
I cannot find this anywhere, and it is holding up a project. I have a
*very* simple rails app with three tables, one of which is the users
table:
users:
Column | Type | Modifiers
---------------+-----------------------------+-----------------
id | integer | not null default nextval(''public.users_id_seq''::text)
login
2006 Apr 16
2
conditional updated_on update
Hi list,
I''ve got some counter_caches in a model. When these get incremented - say on
a page view - my updated_on column also gets updated. How can I
conditionally not update updated_on if just these counter_cache columns
change?
The problem with that is that I am using acts_as_versioned which clones the
record each time updated_on changes. I am successfully ignoring the
counter_cache
2008 Jun 16
2
call_backs Is it?
Hi
I have the models
1.ServiceDeskTicket with fields
id --- number --- service_desk_status_id -- created_on -- updated_on
etc
2.ServiceDeskActivity with fields
id -- service_desk_ticket_id -- description -- created_on --
updated_on
3.ServiceDeskAttachment
id -- service_desk_ticket_id -- attachment -- created_on --
updated_on
Relations as
ServiceDeskticket has_many
2007 Aug 14
1
find_by_sql vs connection.select_all
I was trying to do SUM based mySQL query simliar to the following:
SELECT SUM(updated_on - created_on) AS total from signups
If I were to run this command in the mySQL console I would get a
result. However, if I were to run it using the following command in
Rails:
Signup.find_by_sql("SELECT SUM(updated_on - created_on) AS total from
signups")
The query that is written to the log is:
2007 Dec 13
2
Trying to use ActiveRecord STI but fails
Hi all,
I''m wondering about my sanity here. There''s probably something simple I
overlooked. First off, I have close to zero experience with Merb.
1. I configured use_orm :activerecord in config/dependencies.rb;
2. I have a file named app/models/measurement.rb which looks like this:
class Measurement < Observation
end
3. I have another file named
2006 Mar 22
3
STI and ActiveRecord attributes unprotected
Hi,
This does not seem to be covered anywhere. Since base class extends
ActiveRecord with a table that has fields for all heirs, would that mean
that any heir class can access any of those attributes, including ones
that belong to other heirs?
Or I am missing something?
--
Posted via http://www.ruby-forum.com/.
2007 Mar 04
2
BgDRb blocking in ActiveRecord
Hi Folks,
I''ve got a tiny little problem using MySQL-backed ActiveRecord in my
worker class. Sometimes it just blocks infinitely when I try to
access it. I don''t know whether it is in AR itself or in the SQL
driver. It just stops doing anything, logging nothing, no exceptions
are raised. I don''t know if it matters that I call the worker''s
methods via
2006 Jan 14
11
nuby: do models have to inherit directly from ActiveRecord?
Hello,
I have a few models -- book, cd, dvd -- for which I''d like to have an
abstract base superclass to hold some common stuff. That abstract class, I
was thinking, would inherit from ActiveRecord.
Didn''t work, though, and looking around, I found this:
<http://wiki.rubyonrails.com/rails/pages/HowtoMakeAbstractModel>
2007 May 28
5
CTI in ActiveRecord
I search an plugin or gem, but don''t find nothing satisfactory. I
believe to be stranger a technology that nails the DRY, have that create
you vary equal tables, instead of using inheritance.
Exists an soluction for this? I want a solution similar to this:
create_table :people |t| do
t.column :name
t.column :address
end
create_table :customer |t| do
t.column :person_id