Displaying 20 results from an estimated 10000 matches similar to: "How to find() only selected columns ?"
2006 Apr 23
4
ActiveRecord: Exclude some columns while fetching
I have models with large TEXT, BLOB columns and I don''t wanna fetch them
everytime. Is it possible to omit columns when fetching records from DB?
Sorry, if it''s trivial, but I can''t find helpful information in docs.
2005 Mar 07
1
Legacy DB Guide?
I''m looking at using RoR for a system tying in with a legacy DB that
can''t be modified (other apps using etc). It uses stored procs
extensively.
Searching for some kind of a guide / tutorial etc for handling this
kind of situation I''m only coming up with a bunch of 2 paragraph
articles saying "RoR is great! but there might be some trouble with
legacy systems".
2005 Dec 29
1
Resolving ambiguous columns during a join
I am working with an existing schema and thus limited in how much I can
bend my existing column names. I have a table Users, and a table
ForumUsers, for which I have a "has_one" relationship - a user has_one
forumuser. When I look at my user records I wish to include some
information from forumuser:
@users = User.find :all, :include => :forum_user, :order =>
2006 Mar 04
10
Help setting up relationships needed
This is a bit of a long question, but to those of you with some
experience, it should be fairly simple I think.
I have a notes page that should list all notes the user has entered for
all books chronologically like this.
Book One: This is the note.
Book Four: This is the note.
Book One: A different note, entered later.
Right now my models are:
User
has_many :books
Book
has_many
2006 Mar 02
3
Left Joins with Rails?
Everyone,
I have two tables (assuming their most logical types):
apartments
id
address
bedrooms
bathrooms
googlemaps_id
googlemaps
id
url
the models:
class Apartment < ActiveRecord::Base
has_one :googlemap
end
class Googlemap < ActiveRecord::Base
belongs_to :listing
end
I would like to find_all by searching the attributes in apartment, and
also return the google map
2005 Dec 19
4
need some help designing my messaging system
I am trying to create a messaging system for my users but I''m having a
hard time designing my db. This is what i have in mind, but I am not
sure if its the best approach.
user has_one inbox
user has_one outbox
inbox has_many messages
outbox has_many messages
inbox table
user_id
outbox table
user_id
messages table
box_id (refers to either inbox or outbox - how?)
from_id
to_id
2010 May 25
2
Site Navigation With Polymorphic Has Many Through
Hi, seem to keep running into a wall here. I can''t find any resources on
site navigation that can deal with any model being in the nav, allow
nesting, and can dynamically update.
So I thought about it for a while, and decided on a MenuItems class, which
contained the position of the child in relation to it''s siblings, where the
parent and the child were polymorphic. Then a given
2006 Feb 26
3
Rails Naming Conventions
DB field names:
If I have a table that references 2 or more separate users from my users
table, is there a recommended naming convention for this situation? In
my case, I have 3 users associated with a record in my projects table:
requester_user_id
created_by
updated_by
I could name one of them "user_id", and then projects.user would work I
guess, but wouldn''t work
2006 Apr 11
5
Multiple "has" in ActiveRecord
Please excuse a newbie question, but I couldn''t find anything by
searching the archives.
What I want to know is how to have multiple references to the same
class/table within a class. For example, let''s say I have a table called
People:
create table people (
id serial8 primary key
,name);
which just holds a list of the people in the database. Then I have
another
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really
be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again.
I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I
don''t just post it manually: I design a Rails-based inventory database that
creates a semantically-correct XHTML/CSS auction
2006 Mar 07
6
fcgi dispatcher crashing
I''m trying to set deploy an app on apache2 with the fcgid module, but can''t
seem to get anywhere.
Things work fine with cgi, but when i switch to fcgi, i''m stuck with a ''503:
Service Temporarily Unavailable''. There''s no error being logged anywhere,
afaik.
Trying to run dispatch.fcgi from the shell doesn''t work either. It bombs
out,
2006 Aug 16
5
Rails theory question, where to put a join query
The is something I wrestle with a bit when I construct joined queries..
Perhaps some experienced insight will straighten this out for me.
Say you have two tables with two models, ''authors'' and ''posts''.
an author has_many posts, a post has_one author.
You need methods to do the following queries:
find_author(postid)
find_posts(authorid)
And you are doing a
2005 Dec 14
5
belongs_to and multiple foreign keys
Hi all,
I''m confused about how I''m supposed to specify a belongs_to relationship when
the table includes multiple columns that reference the same parent table.
In my case I have a "schedules" table with "opened_by" and "closed_by" columns,
that both reference the "users" table. In theory, they can be two different
user ids.
table
2006 Jul 05
2
Serialized object behaves weird
Hi!
I got a class named EinsatzFilter which I serialized to session. Before
saving to session it works afterwards I keep getting the message:
"undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from
ActiveRecord::Base inherited class.
Code:
class EinsatzFilter
include ApplicationHelper
attr_reader :personen, :monat, :projekte, :kunde
2006 Jan 25
7
join fields for list views
I am sitting with the Agile book on my desk and scratching my head at
the discussion on aggregation - perhaps that isn''t what I need.
I have a db called clients.
fields include - first_name middle_initial last_name
I want to combine them all into one name element in a list view. I can
add/edit the fields separately but in the list view, I only want the one
combo field.
Is there a
2006 Apr 07
5
Confusion about has_many / belongs_to ...
I have a table called players and its model Player, and I have a table
called games and its model Game.
In the games table I have:
player1_id int(11)
player2_id int(11)
I want the tables to be associated so that I can access the player
objects using table.player1 and table.player2 rather than having to
lookup the objects based on the ids.
I am not sure how to go about this but I suspect I
2006 Mar 03
6
has_one :next - invalid name?
I have this in a model:
has_one :next,
:class_name=>''WorkPart'',
:foreign_key=>''next_id''
And it causes this error:
compile error
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/deprecated_associations.rb:83:
void value expression
2005 Apr 18
11
Create a pseudo-model from SQL query?
I''m having a hard time figuring out how to build my application using Rails. As i go
along, simple questions occur to me like: are you supposed to have a separate model
class (each in its own file, in the app/models directory) for each table in your
database? You''d think that something as basic as this would be laid out in the
introductory documentation but, alas, the
2006 Jan 13
4
Single Table Inheritance (this is my 3rd post :( )
Hi Everyone,
I hope I get some feedback on my question. Here it goes.
I have a situation here, I have a company table and then using Single
Table inheritance it is of 3 types:
class Company < ActiveRecord::Base
end
class Vendor < Company
end
class Customer < Company
end
class Agent < Company
end
Now I have a active record Association
class QuoteSheet < ActiveRecord::Base
2006 Jan 05
3
has_one :dependent => true question
Hello,
I have two classes that are self explanatory and are listed below.
class User < ActiveRecord::Base
belongs_to :account
end
class Account < ActiveRecord::Base
has_one :account_owner, { :dependent => true, :class_name => "User",
:conditions => "is_account_owner = 1" }
has_many :users
end
In the signup controller when an account is created one user