similar to: Query for multiple tables with find question :)

Displaying 20 results from an estimated 3000 matches similar to: "Query for multiple tables with find question :)"

2006 Jan 12
5
Question about using DISTINCT in ActiveRecord find method.
Hi, Am relatively new to the RoR world. My question is quite simple. I have a query like such: shipmentNumbers = Order.find_by_sql(["select distinct s.id from orders o, line_items li, shipment_lines sl, shipments s where o.number=? and o.id = li.order_id and li.id = sl.line_item_id and sl.shipment_id = s.id", number]) The above query works fine. I wanted to do the same query using
2005 Dec 14
5
inserting multiple rows
I have table which stores multiple entries. Each row has user_id, game_id and a pick_id. On a page the user has to make load of choices. All this gets submitted. the html looks like so: <input type="hidden" name="game_id" value="3"> <input type="hidden" name="user_id" value="19"> <select name="pick[3]"> ....
2006 Feb 24
7
One To Many To Many
Hey all, I''m trying to find a simple way to reference all of the objects that belong to their parent''s parent. In other words: Clients --> Orders --> LineItems How do I get all of a client''s lineitems in one array (i.e., client.all_lineitems)? Thanks! -Neal -- Posted via http://www.ruby-forum.com/.
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t spec it, see this pastie: http://pastie.caboo.se/53120. When following the link from a browser I''m being redirected to the right page. -------------- next part -------------- An HTML attachment was scrubbed... URL:
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 May 26
4
Using ''validates_inclusion_of'' to validate foreign key
I seem to be missing something trying to use ''validates_inclusion_of'' to validate a foreign key and was hoping some one could piont out my mistake? The problem seems to be that Order.find_all.collect is not returning an array that contains the order_id, if I replace it with a hardcoded array everything works as expected. The model: class OrderItem < ActiveRecord::Base
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 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 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 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 Apr 24
8
Application Design
I have a question about how to implement a design in Rails. I will try to make this as easy to follow as possible. First, let''s say that I have an ''Orders'' table that has different statuses. The 3 statuses that I want to track are ''Submitted'', ''Approved'', and ''Purchased''. I also have 3 users of this application.
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 Mar 31
2
Model inheritance is borken in Rails1.1
following is model code in file order_payment.rb class OrderPayment < ActiveRecord::Base belongs_to :order validates_presence_of :amount, :no end class LC < OrderPayment end class LC30 < LC end class LC60 < LC end class LC90 < LC end class LC120 < LC end class TT < OrderPayment end class CAD < OrderPayment end and following is error i''m getting with
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 May 27
4
MSWord97 installs properly but still won't launch (or save?) -- 3 more data files
Dear friends: Forgot to include three more data files: http://www.websher.net/tmp/user.reg http://www.websher.net/tmp/system.reg http://www.websher.net/tmp/userdef.reg Thank you again. Benjamin I've been trying for some time to install my copy of Word97 (which I own, having purchased it directly from Microsoft with my own license number). I have tried the latest Wine 0.9.14. To do
2007 Sep 05
8
Hi..Guys new plugin again
Hi.. Guys new plugin again Foreign Key Associations is a plugin that automatically creates associations based on foreign-keys. The associations are created at runtime-ie. as your ActiveRecord models are loaded-so they will always be up-to-date. For example, given a foreign-key from a customer_id column in an orders table to an id column in a customers table, the plugin creates:
2006 Dec 07
2
Problem saving parent and children using belongs_to, class_name, and foreign_key
Hi, I have a real simple association setup here that''s just trying to: - Create a new PayjunctionOrder - Create some LineItem objects and assign them to the PayjunctionOrder - Save everything I''m using Rails Edge. ---- class PayjunctionOrder < ActiveRecord::Base has_many :line_items end ------------------ ---- class LineItem < ActiveRecord::Base belongs_to :order,
2012 Jan 26
1
adding additional information to histogram
Hi, I am a beginner with R, and I think the answer to my question will seem obvious, but after searching and trying without success I've decided to post to the list. I am working with data loaded from a csv filewith these fields: order_id, item_value As an order can have multiple items, an order_id may be present multiple times in the CSV. I managed to compute the total value and the
2006 Jun 20
1
ActiveRecord saving madness?
Hello, First of all, I love RoR. I am studying it, and I am finally "getting there". However, I do have a bit of a problem with ActiveRecord''s saving behaviour. Imagine to have Orders (id, name) {has_one:invoice} and Invoices (id, order_id) {belongs_to :order} . If you type: invoice = Invoice.new(...whatever...) an_order.invoice = invoice if invoice fails to save, you
2013 Feb 18
6
How to clear ActiveRecord query cache on associations with dynamic table
In part of my application I''m using dynamic tables. I''m aware of the single thread conditions. I''ve tackled some caveats yet - will post a blog about it soon - but there''s one I need help with. Consider 2 models that are associated: Order and OrderLine where Order has many order_lines. Now we set the table names for them: