Displaying 20 results from an estimated 9000 matches similar to: "Add a SQL Statement to every query"
2009 May 14
3
Mysql query is not working
Please,
Can anyone help me to execute this query?
SELECT * FROM table WHERE customer_id IN (SELECT IF(1 <> 2,''SELECT
customer_id FROM customers'',''SELECT customer_id FROM company''))
Regards...
--
Posted via http://www.ruby-forum.com/.
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:
2007 Jan 08
1
Realtime Voicemail Table Column Name Question
Hi All,
In the realtime voicemail table the column 'customer_id' is used, for
my purpose, to specify the customers accountcode. The column name
'accountcode' is used in the iax and sip tables. To keep this
consistent throughout the tables, is there any reason I should NOT
switch the column name 'customer_id' to 'accountcode' in the voicemail
table? Does Asterisk
2007 Sep 21
2
ActionWebServer and SOAPFault
I''m really new to RoR and my first task is to write SOAP web service.
The problem is that I don''t understand how to send custom SOAPFault
messages in case of the errors.
For example, I have FindCustomerById API signature:
api_method :find_customer_by_id,
:expects => [{:customer_id => :int}],
:returns => [Customer]
And controller:
def
2007 Mar 07
4
Strange Problem With Unwanted, Transient Caching
Hello,
I hope somebody can explain to me what''s going on here because I''m
baffled!
In a controller''s action I want to create a new order for a
customer. Because I post back to the same action (not RESTful I
know, but that''s for another day) I use code like this:
def edit
@order = Order.find_by_id(params[:id]) || Order.new
...
end
I
2005 Dec 07
3
ActiveRecord::Observer problem
Hi all,
I have a problem with an observer. I have a simple observer...
class ActivityObserver < ActiveRecord::Observer
observe Customer
def after_create(model)
bind_params(model)
@al.action = "create"
@al.save
logger "#{model.id} : created"
end
private
def bind_params(model)
@al = ActivityLog.new
@al.user_id = User.current.id
2006 Jun 17
2
how to delete a parent record and child records?
Wow, got myself lost as *soon* as I left the hand-holding exercises in
the books.
I''m trying to set it up so when I click the (scaffold-generated)
''destroy'' link on one (of a list) of parent MySQL records, the children
records in a different table get deleted also.
Very simple setup: my tables are ''customers'' and ''accounts''
class
2009 Oct 29
4
Unknown column 'quotes.organisation_id' in 'where clause': SELECT * FROM `quotes` WHERE (`quotes`.organisation_id = 1036)
Hi,
I have a small app that needs to keep track of quotes, and
organisations. An organisation can either be the unit who finally
receives the goods (the end_user) or and intermediary (customer) (and in
some cases both)
An Organisation will (hopefully :) ) have many quotes; and a quote
can belong to an organisation, either as a customer or as an end_user or
both.
So the quotes table
2006 Apr 03
1
Single table inheritance and relations
All,
I''ve a question concerning STI in Rails. Let''s say I''ve a Person class
and two classes that inherit from Person: User and Customer. In the DB
I''ve the people table to store both instances of User and Customer.
Now, let''s say I also have Address class, which references a Customer,
and each customer has many addresses. How should I name the
2006 Feb 27
3
Newbie Question
Hi! I just ran the first few Rails tutorials and I''m really impressed
at how quickly I was able to get something up and running.
I''m slowly emerging from the stone ages, and leaving my powerbuilder
behind ? yes, I know, keep the snickering to a minimum please! I
started into J2EE/STRUTS, but was quickly frustrated by how long it
would take to code anything but relatively
2011 Apr 01
4
add_column not working in migration for sqlite3
Hello,
I developed an app with postgres DB but want to change the DB to
sqlite3. I changed the database adapter in the database.yml file. When I
run the migration most of it was successful but add_column was throwing
an error
"Cannot add a NOT NULL column with default value NULL: ALTER TABLE
"rates" ADD "customer_id" integer NOT NULL".
I made the modification and
2006 Jan 04
3
How Can I solve this?
this may be an easy question, but i am unable to solve it:
i want to take the selected choice and process it in the controller:
TEMPLATE:
<%=start_form_tag :action => ''get_article'' %>
<select name=pricelist>
<%= options_from_collection_for_select (@customers, "id", "name") %>
</select>
<%= submit_tag "Get" %>
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 Aug 03
0
sql question
In my rails application I want to run something like a report
my table is like this
id
custommer_id
oranges
lemons
Select sum(oranges),sum(lemons) from my table
group by " MAGIC GOES HERE "
order by custommer_id
MAGIC GOES HERE = group by 3 registers......
like
this
id| customer_id | oranges | lemons
1 | 1 | 5 | 6 |
2 | 1 |
2009 Aug 18
4
pagination problem....
Hi,
please help...
In controller...
def index
@customers = Customer.find(:all)
pagination code here....
end
In index.html.erb
Displayes list of customers and has pagination 1,2,3,4...etc.
On clicking page 2, it will again run this(Customer.find(:all)) query in
controller. So, there will be lack of performance.
So, how to increase the mysql performace? Can i use the index as below
or any
2006 Feb 23
2
create_for_*
Hi!
If I have a /budget/create action, how should I make a
/budget/create_for_customer without repeating myself?
I could create a "create_for_customer" action and call "create" from
there, but stripping the customer select_tag somehow, since customer_id
will be passed from /customer/show.
How do you do the create_for_something stuff?
Thanks,
Rodrigo.
--
Posted via
2008 Nov 03
17
SQL queries in Rails
Hi...
I want to know the equivalent instructions to insert, update, search
and delete a registry. I know Rails can do it easily Thanks to
ActiveRecord, but here''s the catch: I''m using PostgreSQL. As I''m using
SQL to do the migration (Including the foreign keys), I need to know
if I can use SQL queries to do those actions. Is there an example out
there?
I uncommented
2005 Aug 11
5
Realtime + MYSQL
I'm having a few issues with the MySQL realtime configuration in
CVS-HEAD. I tested it initially with realtime extensions (realtime_ext
=> mysql,asterisk,extensions) and a realtime switch in extensions.conf
and that works fine, So I though I'd go back and test a static
configuration mapping.
I used the table structure from the asterisk guru postgres howto to
create something
2012 May 03
1
AMI disconnects
Hi all.
I've got a perl script that connects to Asterisk's management interface using Asterisk::AMI. So far, its proven to be very useful.
I'm hoping to use this to detect and respond to asterisk restarts and sip reloads.
However, my script gets disconnected quite frequently, causing false alarms in my monitoring.
Here's what the code looks like:
2007 Sep 10
6
RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to)
Thanks, first, to everyone who''s asked and answered questions on this list,
and to the creators of RSpec - it is all very helpful. I''ve searched the
mailing list, and had a couple 2hr googling sessions that didn''t help me
find an answer.
I''ve run into a problem getting my first non-trivial view spec to run. I
get an error when trying to generate a link_to()