Tagged Questions
0
votes
1answer
16 views
Working with existing database of a rails project
I want to run a ruby on rails project in my Ubuntu 12 mechine.After running the command bundle install i used the following command
rake db:drop db:setup
it shows
-- ...
0
votes
0answers
10 views
Active Record sql query not getting logged
I am facing a weird problem for sometime, wherein the active record queries are not getting logged in the terminal, or from rails console (using ActiveRecord::Base.logger = Logger.new(STDOUT)). The ...
2
votes
1answer
40 views
Mysql 5.6 headaches on Mac OSX
Several of my colleagues and I have recently upgraded from MySQL 5.5 to MySQL 5.6 using homebrew on our Macs to test locally before upgrading our servers. Since this upgrade, we all have been ...
2
votes
3answers
20 views
How can I select the record with the latest date in each group
I have a table which we'll call table:
table(id: integer, pid: integer, end: datetime)
that has the following data:
table:
id pid end
1 1 1
2 1 2
3 1 3
4 2 11
5 ...
2
votes
1answer
38 views
Where should you store a lot of custom Strings in RoR?
I have a portal model. Every user gets their own portal. Now the user can customize various strings across multiple pages on that portal to show their customers. Overall there are around 50 strings ...
0
votes
0answers
29 views
Mysql index with multiple columns
I am using Rails 3.0.20.
My DocVisit model looks like
default_scope where(:active => true)
belongs_to :customer
belongs_to :department
belongs_to :order
belongs_to :patient
I have following ...
4
votes
4answers
613 views
where is my database located when using mysql in rails?
I am learning to use mysql for rails apps, and I finally have been able to get my app up and running (sort of, for now). I managed to install mysql with homebrew, and then populated my database.yml ...
4
votes
1answer
31 views
How to write nested query in ruby on rails?
i want write a query for the following using where method
SELECT * FROM videos
WHERE 'privacy' = 'public' OR
(privacy = 'private' AND
id IN (SELECT vid
FROM vid_ads
...
0
votes
1answer
13 views
Migrate old php site database to rails with legacy script and mantain old ids
I'm trying to migrate my old php website database (mysql) to a rails 3 app (mysql) by a rake legacy script like this:
How to migrate legacy PHP mysql data to new Rails data model?
but i have a ...
3
votes
3answers
311 views
Query intersection with activerecord
I'd really like to do the following query with the help with active record
(select *
from people p join cities c join services s
where p.city_id = c.id and p.id = s.person_id and s.type = 1)
...
0
votes
0answers
26 views
How to easily switch database type (MySQL and MongoDB) in rails without duplicate models code?
For a project, i need to be able to deploy it with either MySQL or MongoDB (I'm currently using mongoid for that). My question is, is it possible to make "standard" models (especially about the ...
2
votes
2answers
2k views
Rails: specifying a different database in the model
I'm trying to set up Rails (v3.2.2) to use multiple databases. I'm doing this based on this Connecting Rails 3.1 with Multiple Databases.
My model:
class Category < ActiveRecord::Base ...
2
votes
2answers
766 views
Can't get mysql2 gem to install. Install can't find mysql.h
I am trying to install mysql2:
sudo gem install mysql2 -v '0.2.7' -- --with-mysql-config=/usr/local/Cellar/mysql/5.5.25a/bin/mysql_config
I'm getting this error:
ERROR: Error installing mysql2:
...
0
votes
1answer
58 views
Rails config/routes.rb file is not working (see body)
When I start rails server via command line: rails server, or via RubyMine (just hitting run button) server starts just like it's expected.
Console output:
/usr/bin/ruby -e ...
0
votes
0answers
17 views
How to debug frequent connects to the database
How to debug frequent connects to the MySQL database running as a RDS instance (using mysql2 gem) of my Rails 3 application. I have the reconnect bit set to true, so it keeps reconnecting, but I am ...