0
votes
1answer
19 views

Postgres Copy from Variable with CSV data

I know you can run a copy command like this from a file: "COPY zip_codes FROM '/path/to/csv/ZIP_CODES.txt' DELIMITER ',' CSV;" I'd like to copy csv data from a ruby variable so I can do like so ...
1
vote
2answers
40 views

How do I switch the database used in a Rails application?

I have an application based on the Devise cancan repo. Currently it is using SQLite3 as its database. I was wondering how someone would change the system to something like MongoDB or a SQL database? ...
30
votes
9answers
13k views

postgreSQL group by different from mysql?

I've been migrating some of my mySQL queries to postgreSQL to use Heroku... most of my queries work fine, but I keep having a similar recurring error when I use group by: ERROR: column "XYZ" must ...
2
votes
4answers
2k views

Rails: Get next / previous record

My app has Photos that belong to Users. In a photo#show view I'd like to show "More from this user", and show a next and previous photo from that user. I would be fine with these being the ...
2
votes
1answer
43 views

Rails first_or_create adds (1=2) to query

While running development code through Heroku console in sandbox mode, I use first_or_create to test for existence of a record: Right.where(:language => language ). ...
1
vote
3answers
43 views

Rails join - find records that don't have a join matching a specific condiiton

In my Rails 2.2.2 app I have two tables/models joined like so: School has_many :licenses, :as => :licensable License belongs_to :licensable, :polymorphic => true #important fields for ...
1
vote
2answers
4k views

Incorrect MySQL client library version

I created a new rails project calling rails new simple_cms Then when in the directory I run rails s I get the follow errors ...
9
votes
1answer
6k views

How Do I Search Between a Date Range, Using the ActiveRecord Model?

I am new to both Ruby and ActiveRecord. I currently have a need to modify and existing piece of code to add a date range in the select. The current piece goes like this: ReportsThirdparty.find(:all, ...
0
votes
1answer
58 views

inner join two tables with limit

I've seen this post that is almost the same with my question but my problem is, I need to put a limit to the third table/query, like LIMIT 15. Is there a way that I can do this? Thanks! EDIT My SQL ...
0
votes
2answers
37 views

SQL-query for 'version-control' feature

I am doing something like 'version-control' of the document that is being uploaded. So when I upload a new document, I check if there is already a document with same name in the table, and if there ...
0
votes
3answers
27 views

Stored procedure vs multiple queries (activerecord)

Just got started with activerecord. I am just wondering if I am making multiple queries in a request, is it better to have a stored procudure? That way, I am making 1 SQL query as oppose to multiple. ...
0
votes
1answer
25 views

Optimize nested SELECT query and do it with ActiveRecord query API

I have this SQL query to select some of my offers and it works as expected. SELECT * FROM `offers` WHERE region='26' AND EXISTS ( SELECT * FROM `modificator_values` WHERE ...
0
votes
1answer
28 views

Modifying date to enable search in mysql DateTime format

I have an UI, in which we which we select a date range, and then perform a query to check orders within that range. So the valid formats accepted are a) 2013-04-01 17:00:00 - 2013-04-16 18:00:00 b) ...
0
votes
1answer
39 views

SQL Chain (joins and wheres) - Ruby

I'm trying to make a search filter, and all params are the names of the check boxes so they are arrays filled with id values. @sql_query = '' if filters_benefit_type.nil? == false @sql_query = ...
0
votes
1answer
58 views

Order results based on ordering of IDS passed to IN

Given ids = [4, 2, 1, 3] dishes = Dish.where("restaurant_id in (?)", ids) Would it be possible to sort dishes based on the sequence of ids? => # I'd like to see something like this => ...

1 2 3 4 5 97
15 30 50 per page