0
votes
1answer
23 views

Two users associated with the same record?

In my Rails application I have a Prescription model. Currently each Prescription belongs to a User and each User can have multiple Prescriptions. The Prescription is owned by the User that created ...
0
votes
2answers
32 views

Creating a Mysql user within a Rails controller action

Working on an app that wil be used by admin only to create multiple instances of another app. In other words, app A will be used to create clones of app B on server and create all the configurations ...
0
votes
1answer
22 views

two of the same foreign key from the same table into another table?

Is it ok to have two columns in a table that can be a foreign key from the same table? For example: i have an 'address' table with columns: id, street, city_id, state, country (or id, street, ...
0
votes
1answer
34 views

gem install mysql not working. But i'm able to connect to mysql -u root -p

I'm using ubuntu based backtrack OS. I have mysql installed and i'm able to stop, start, connect to mysql. mysql -u root -p works fine and able to create database and could be able to see data in ...
1
vote
2answers
36 views

mysql/RoR database design

Is it ok for a table to have two of the same foreign keys as columns? I.e I have two tables, one is Country, the other is City. In the Country table: COUNTRY -------------- id name capitalcity ...
0
votes
1answer
33 views

Rails ActiveRecord find User where Products equals 0

I have a model User that has_many Product(s), but some Users don't have any products yet. I want to write a query that gives me all the Users who don't current have any Products i.e. a User where ...
0
votes
0answers
15 views

Getting undefined method `orders' for #<ActiveRecord::ConnectionAdapters::Mysql2IndexDefinition

Using activerecord-mysql2-adapter, I am getting undefined method `orders' for #<ActiveRecord::ConnectionAdapters::Mysql2IndexDefinition This is when I run rake db:schema:dump. I am trying to get ...
2
votes
3answers
164 views

Handling two almost identical tables as one model

I'm working on creating some models for the wikimedia databases located on wikimedia labs, and due to technical issues, there are two tables for revisions. One table revision contains all revisions, ...
0
votes
2answers
62 views

how to insert hash into mysql using ruby

Let's say I have a hash: {"MemberId"=>"MID-0000001", "MemberName"=>"Bruce", "OrderNumber"=>"ON-000000001"} How can I insert this hash into orders tables of the db database in mysql? ...
0
votes
0answers
30 views

Saving and retrieving sales data from MySQL [closed]

How can I save sales data in a MySQL database for a particular date range? For example, between 01-06-2012 and 30-06-2012 I add 120 (4 articles sold each day) after that I add between 10-06-2012 and ...
0
votes
2answers
30 views

get a list of cities from location model and how many locations exist for each city

I have a location model which has a few columns: title, address, city, state, etc... I am trying to show a list of all the cities based on the locations in my database. Then, I am trying to figure ...
0
votes
3answers
25 views

Able to add myself as friend in rails console

I have built a user and friend relationship model but the problem is that with those associations I can friend myself. I have successfully suppressed it in my views and controller, but logically it ...
0
votes
1answer
30 views

How to group by day and year in Active Record in Rails3

I'm trying to recreate the following mysql query in rails 3 select count(id), year(created_at), month(created_at) from table where published_state = 'published' group by year(created_at), ...
1
vote
1answer
77 views

how to use Tire for getting data from Elasticsearch index and without hitting database

I am using Tire for implementing Elasticsearch. My environment is Linux,Rails 3.2 with Ruby 1.9.3. I am able to index using Elasticsearch with the help of gem Tire(0.5.8). But now to improve ...
0
votes
2answers
29 views

How to use user defined variable of ruby in mysql?

I'm working on Rails 3.2.9 app with ruby 1.9.3 and mysql 5.5. I'm required to write a query where in i'm supposed to use a user defined variable in the where clause in my controller file. Here's the ...

1 2 3 4 5 48
15 30 50 per page