similar to: Problem with find and join (wrong id?)

Displaying 20 results from an estimated 11000 matches similar to: "Problem with find and join (wrong id?)"

2005 Nov 24
1
Log question
development.log contains quite a few SELECTS on system tables like COLUMNS. Wouldn''t it be more efficient to cache this info? I''m also wondering about strings like "[4;35;1m". What''s their purpose and is it possible to get rid of them? They look like screen coordinates and makes no sense in a text file. Christer Processing ReportController#create (for
2006 Jan 06
2
Paginate from a difficult sql query
Hello, I have 2 tables table colors : +----------------------+ | id | user_id | name | +----------------------+ | 1 | 1 | test1 | | 2 | 2 | test2 | | 3 | 3 | test3 | +----------------------+ table users : +----------------------+ | id | enabled | name | +----------------------+ | 1 | 1 | bob | | 2 | 1
2006 Oct 02
2
when to use find_by_sql
I have a bunch of queries to compute some counters, like find_by_sql(<<-SQL SELECT p.*, c.nfavourites FROM people p, ( SELECT fp.person_id, COUNT(fp.user_id) as nfavourites FROM favourite_people fp, users u WHERE fp.user_id = u.id AND u.cluster = ''#{in_cluster_of_user.cluster}'' GROUP BY fp.person_id ) as c WHERE
2006 Jul 30
3
Accessing @org.id yields internal number, not record id
With apologies, I can''t figure out the simplest thing: How to reference a record id instead of the internal memory location of that value. I''m new to Ruby but otherwise a veteran VB6/SQL programmer. My code: <snip> sSQL = "SELECT id, org_name FROM organizations WHERE user_id = ''#{sUserId}'' AND user_password =
2006 Jul 15
3
How bad is it to have 7 joins in my find_by_sql?
My question is whether there''s a more idiomatic rails way of structuring this query or of redoing the underlying models. First, the ugly find_by_sql code, which is the method to generate an atom feed: def atom items_per_feed = 15 sql_query = "SELECT activities.*, users.real_name AS real_name, accounts.last_scraped_at AS last_scraped_at,
2006 May 13
4
undesireable lazy loading
Hi, My work with Rails has been fairly straightforward, until yesterday... I''ve encountered rather a peculiar problem that I''m not able to solve myself as a rails-newbie. The model code looks like this: class Link < ActiveRecord::Base has_one :user_vote end class UserVote < ActiveRecord::Base belongs_to :user belongs_to :link end I have a SQL query that is
2006 Jun 13
2
Query for multiple tables with find question :)
Hello all, I am trying to figure out how to do this with find instead of doing it via find_by_sql For example I am trying to list all my completed orders, however I need to check the progresses table to make sure the "currentlevel" in the progress table equals "endlevel" in the orders table. The sql below works fine, but I am just curious how to do it another way. def
2006 Jan 19
2
NOOB: Using locals to pass data to a SQL query
I want to show a users entries based on there login id. I have tried this: View: <div id="myfish"> <%= render :partial => ''myfish'', :locals => {:user => session [:user].id } %> </div> Partial: <% for entry in @entries %> <table border ="0" CELLSPACING="0"> <tr class="<%= alternate
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 Mar 20
2
subsetting and NAs
R-help, I'm getting some unexpected behavior with subsetting a data frame (aircraft flight data) that I can't sort out. Here is a simplified version of my data frame and problem: > flight FlightID TailNo FlightDate HobbsTime FlightCost Date year 1 4497 6009K <NA> 2.2 330.0 <NA> NA 2 4498 6009K <NA>
2006 Feb 02
3
What is best way to show only records belonging to logged user?
Hi all, What is best way to show only records belonging to logged user? I understand that it is better to handle this in model and not controller. I am thinking of intercepting find methods in model and add clause something like "WHERE id_user = #{user_id}". I would like to hear if you would do it likewise and if yes is it better to hack find_by_sql() or find() method? thanks in
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.
2009 Apr 29
0
Polymorphic comments table needs associated model
Howdy, I''ve been banging my head on this problem for a bit. I''m using the acts_as_commentable plugin which works great. The scenario, I''m on the user''s dashboard and want to display comments with commentable_type = Venue. No problem. But, if I want to display the name of that Venue with the comment... big nasty. The polymorphic key is a composite key and
2006 Apr 12
0
Looking for a simpler model using :through associations
Hi. I''m building a setup where I have users and groups, and a user can have an optional title in a group (eg. "owner"). I''m doing this using "has_many :through" associations, using a Role model object as the join hub: class User < ActiveRecord::Base has_many :roles, :dependent => :destroy has_many :groups, :through => :roles end class
2006 Mar 02
1
Coding conventions (mostly AR)
I have the following tables: Users, Clients, Roles, Assignments(user_id, role_id, client_id) and Rights(controller, action). First of all, I''d like to know if hooking things up this way makes any sense. Could perhaps add a second join table between assignments and roles, but not sure that would add any value. What i''m really wondering about, though - is how to do things the
2006 Feb 02
0
What is best way to show only records belonging to loggeduser?
When I do this, I store the after a successful login. user''s id in session. My controller actions pass that id into the find method @tasks = Task.find_all_by_user_id(session[:user_id]) The session would have to be hacked in order for that to be broken. It''s been secure enough for me. -----Original Message----- From: rails-bounces@lists.rubyonrails.org
2006 Aug 30
3
extracting username
Forgive my ignorance ya''ll. I''m trying to extract a username from a table using the user id. I''ve tried: @authenticated_user = User.find(:first, :select => "login", :conditions => "id = ''1''") AND: @authenticated_user = User.find_by_sql("select login from users where id=''1''") within an action that
2006 Sep 28
5
Eager loading using find_by_sql
Here''s the problem I have the following models User - is a person Team - is a team Wherenote - snipet of info about a user''s whereabouts on a certain day Team has_and_belongs_to_many :users User has_and_belongs_to_many :teams has_many :wherenotes Wherenote belongs_to :user each Wherenote has a note_date On one page I want to pull back all the Users from a particular Team
2006 Feb 21
6
Select articles from group with id ''1'' and id ''2''
I have to tables: "articles" and "groups". Between I have article_groups as a jointable. Now I want to select every article who is a member of group with id ''1'' and id ''2''. Whats best way to get that? Extract from schemas: CREATE TABLE articles ( id int auto_increment, ingress text NOT NULL, story_text longtext, constraint fk_items_users
2006 Jun 22
3
best way to generate sums of groups
I''m a rails newby, so I''m trying to wrap my head around how to tackle this, since my first few attempts failed. Let''s say your database looks like this: Users id, name, created_at Points id, user_id, value, created_at Users complete different tasks and are awarded varying levels of points, which are recorded in the Points table. What if you wanted to display a