Tagged Questions
1
vote
1answer
14 views
Database models and migrations explanation
I would like to confirm that I understand how database models and migrations work from someone who knows this subject better than myself.
Model: How the database is structured and how the data is ...
-2
votes
0answers
13 views
Rails CRUD database without migrations
In Rails can you CRUD a database without using db migrations?
Let's say I have a Rails app where a user selects options on which materials he used for a building project and how many of each. 1 block ...
0
votes
2answers
23 views
Retrieving the previous 3 posts with the same product ID
The platform I'm trying to build has a little sidebar which should display the previous posts that are have the same product ID. So that the user can easily navigate to more resources categorized ...
0
votes
0answers
20 views
nesting databases and using the data
I'm new to rails, 2nd week at it actually - I'm in an academy, and I've hit a wall.
I have 2 databases, posts and comments ... comments belongs_to post and post has_many comments.
I've gotten my ...
0
votes
1answer
20 views
Specify authentication database in mongoid.yml
I'm trying to authenticate through mongoid.yml, but the user I want to authenticate as is in the admin database. If I try to specify the admin database in the database field, it will put all the ...
-3
votes
0answers
17 views
Mobile DB vs. Webserver [on hold]
Case 1: Mobile User Syncs in morning and pulls updates and tasks for the day.
Mobile user goes offline and updates a record on his device
Web admin updates the same record after the mobile ...
0
votes
1answer
19 views
Basic rails database opinion needed
I'm building a teaching app that contains "courses". I would just like some opinions on the best way to store that the user completed the course.
I guess I could do a has_many to has_many courses to ...
0
votes
0answers
35 views
Rails MySQL migration, changing text column to decimal
I have an items database with a text column where a user would enter a number and it was saved as a string.
I need to change the column to a decimal, I have it working in postgresql from follwing ...
0
votes
1answer
15 views
Migrating db in Heroku RoR error
Hello and thank you in advance for your time racing this,
I am new to RoR and i´m following RUBY ON RAILS TUTORIAL by Michael Hartl, I got really stuck with this error when im trying to migrate the ...
0
votes
1answer
26 views
store remote data in database
I've created a autocomplete searchfield in which users can type a movie title and it will show all the results like this > http://i.imgur.com/Si9Fffv.png
The next thing I want to do is give the user ...
0
votes
1answer
19 views
Browser shows MySQL error that I don't have a column
My schema in rails clearly shows that I have the column named "position".
create_table "tasks", force: true do |t|
t.integer "subject_id"
t.string "name", limit: 50
t.string ...
-1
votes
1answer
30 views
How to easily clone a production postgresql database to staging [duplicate]
I have data in a production database but want to test out some new features so I've set up a staging environment on the same server and want to use the data from the production database with my ...
-2
votes
1answer
35 views
save JSON data to rails database [closed]
I've created a autocomplete searchfield in which users can type a movie title and it will show all the results like this > http://i.imgur.com/Si9Fffv.png
The next thing I want to do is give the user ...
0
votes
1answer
16 views
Rails - Linking existing models in HABTM
I have two models like this
class Student
has_and_belongs_to_many :classrooms
end
class Classrooms
has_and_belongs_to_many :students
end
I want to take a student and link him to a class that ...
0
votes
3answers
23 views
Rails - both model are has_many
Sorry, I am not very advanced in mapping out databases
I have a model similar to this: A teacher can have many students, and a student can have many teachers. So How would I make this? If a student ...
1
vote
1answer
20 views
Rails Logic ! Pre Order ads, how to store the information?
In an app, a client can pre command many ads.
What's the better way to store this information :
#1
Create empty ad with "pre-order" state
#2
Use a pre_order_ads column in the database to store the ...
0
votes
4answers
45 views
Rails: dynamic columns/attributes on models?
I have a SaaS application, where accounts want to save different types of information on a User model. So for example, one account may want to save age, and birthdate, but in another account, they ...
0
votes
1answer
20 views
Rails 'label' value to be save to database
Is there a way or is it possible to save in the database the value of the label tag?
<div class="field">
<%= f.label :cust_name %><br />
<div><label id="cust_name" ...
0
votes
1answer
32 views
Best practice for ordering values in an ActiveRecord database by a 'given value' of string in Rails?
I'm sure this is a common issue when working with databases, but I'm trying to set up an ActiveRecord database in Rails (although I think this would apply to most database systems), so that I can ...
0
votes
1answer
22 views
Rails: If views are 'dumb', from where do I tell my database that a piece of content has been viewed?
I am putting together an e-learning module in Rails which keeps track of a user's progress. I'd like progress to be updated as content is viewed and for each piece of content to have an index id that ...
0
votes
1answer
16 views
Null-ConstraintException on submitted value
I am trying to use Devise in my Rails project, but everytime I want to sign up as a User, I get the following error:
SQLite3::ConstraintException: users.password may not be NULL: INSERT INTO "users" ...
0
votes
3answers
35 views
Ruby on Rails - Double association database
I have this situation :
user.rb
has_many :games
item.rb
has_many :games
game.rb
belongs_to :user, :foreign_key => 'user_id'
belongs_to :item, :foreign_key => 'item_id'
Item :
id : 13 | name ...
0
votes
1answer
28 views
Rails - Complex data modeling relationship between 3 tables
I'm facing the following problem, I'm still fairly new to rails and I need your help
I have a table SALES with 4 columns: product_id, quantity of the product sold, the seller and the day of the ...
0
votes
0answers
22 views
Complex calendar architecture advise
Context
I'm currently building a prototype calendar and need some advise on how to implement a scalable database architecture. I'm using Rails and here is what I did so far :
The event system has ...
1
vote
1answer
52 views
Accessing a database field via current_user in Rails
I'm fairly new to Ruby AND Ruby on Rails, so please bear with me...
I'm designing an e-learning and I want the database to track a user's progress. Users can log in, edit their profile etc; That all ...
1
vote
1answer
57 views
“Connecting to database specified by database.yml” in Rails production
I've deployed a Rails 3 app on Ubuntu server and when I open the app in the browser, there's the 500 error screen and in the logs (production.log) I see following:
...
Connecting to database ...
0
votes
0answers
25 views
Why do images being sent to a rails gallery model with correct associations not show up?
I have a gallery that allows people to upload images to a book. My gallery has_many :images and my image belongs_to :gallery. The form for the gallery has a nested form for the image fields and that ...
0
votes
1answer
31 views
Postgresql depend on record id
I am working on an application design, using Ruby on Rails and Postgresql. I have a table with the following fields
Table: account_type
Fields: id(primary key), name(String)
AccountType name is ...
-1
votes
0answers
14 views
Upgrade database on Heroku and save current results
Is there any way to upgrade database schema on Heroku and keep the current results/records in database?
I've changed my database schema locally and I want deploy the changes on Heroku, but I want ...
0
votes
1answer
30 views
How to Access Rails DB via a Ruby Gem
I am trying to make a simple Ruby Gem that accesses a Rails Database (let's say sqlite) and exports it to a CSV file, via a command line executable.
I am having trouble figuring out how to get to the ...
0
votes
2answers
39 views
Database setup and design for 15 questions game - PostgreSQL and Rails
I am working on a small game where people have the ability to create 15 question quizzes. I am struggling to figure out how to structure my database for the best optimization. The questions each have ...
0
votes
1answer
14 views
How to properly setup checkboxes to save to database using Rails 4 and simple_form?
I've created a form using the simple_form gem but can't get the values of the checkboxes to save. Radio buttons and select fields save perfectly. I have found information on how to use the checkboxes ...
0
votes
1answer
23 views
How to separate rails applications due to postgres database?
I'm new in Ruby on Rails, and even more new in postgres. I have several applications in RoR with postgres db. I would like to separate psql databasis for every of rails app. Now it seems like every ...
0
votes
1answer
36 views
One-to-Many relation using another field except id without bad design of database
I have two models, Restaurants and Deals. One restaurant has many deals and deals belong to restaurants.
There will be no logging in to edit restaurants, only the admin (me) will be able to.
...
0
votes
1answer
25 views
How to set database.yml conditions for each OS?
I would like to set sprocket in Linux and Windows. Both in my database.yml, how to?
Now:
development:
adapter: mysql2
encoding: utf8
database: skeletor_dev
pool: 25
username: root
password:
socket: ...
0
votes
2answers
43 views
Ruby : How to parse a jsonp and save json data to database
I want to parse the JSONP data and save that data into my data base .
I have my jsonp url lets say this ...
0
votes
1answer
37 views
Rails Impressionist making expensive queries
I'm using charlotte-ruby/impressionist to track impressions within my rails app.
I have a very simple implementation, similar to what's shown in the quick start guide. Effectively:
- Controller: ...
0
votes
2answers
45 views
rails db column remember_token is not saved and always nil? [duplicate]
Why am i unable to update a db column in rails?
Database has a column - 'remember_token' but update is not working on it ?
Result of DB migration
....
....
....
== 20140830041234 ...
0
votes
1answer
24 views
Do I need to reset DB every time when I push to heroku?
When I push my local database to heroku postgresql, my current way is to
heroku pg:reset,
then using
heroku pg:push local_db remote_db.
Is there any efficient way to do this rather than ...
0
votes
1answer
17 views
How can I work with my model without a database in ruby on rails?
I want to put my variables with static data (hardcoded) in the model -without database-
and use it with my controller and manipulate the view.
how I can do this in ruby on rails?
0
votes
3answers
45 views
How to create an if statement in database.yml to use different databases based on the current user in rails
as i explained i want to use different databases based on the user.
I got a partner table created with devise and i have multiple databases that i created.Everyone of those databases have the same ...
0
votes
1answer
38 views
Configure a remote sqlite3 database on rails
I programmed an application using rails and I can deploy it on a single machine. It uses a sqlite3 database that is created in the local machine.
Now I need to put that db on another machine, but I ...
0
votes
1answer
19 views
Rails activeRecord patch and commit
I'm working on a tagged blog system using rails. Now it works using join table, but I have some doubt on performance.
Now every time I create a blog and its associating tags, it commits to database ...
0
votes
2answers
72 views
I need help properly forming this ActiveRecord association
Basically, a User can participate in one or more events as either (or potentially both) a vendor and as a member of the event's faculty.
A user is, by default, categorized as neither a vendor nor a ...
-1
votes
2answers
40 views
Need suggestion on DB architecture
I am working on a Project where I have below use case.
User can have many taglines for them , we have lot of predefined data in the DB which we using to show autosuggestion when they started typing ...
0
votes
1answer
34 views
Database structure and calculated rows
Some background
I'm building a bit of a shopping cart. Certain products (not all) are redeemable as indicated by the redeemable field in the products table.
When a product is redeemed, the ...
0
votes
1answer
36 views
How can I do this as 1 database query?
I have a query that looks in the USER table to find the top 9 affiliates based on the frequency of their affiliate code.
affs = User.group(:affiliate).limit(9).count.sort_by{|i,j|-j}
(0.6ms) SELECT ...
0
votes
3answers
25 views
how to write Rails model query between date
This is my sql query I wont to convert into rails model query
sql : SELECT "vouchers".* FROM "vouchers" WHERE "vouchers"."business_id" = 31 AND '2014-08-20' between start_date and end_date;
My ...
21
votes
3answers
9k views
How to solve “Cannot add a NOT NULL column with default value NULL” in SQLite3?
I am getting the following error while trying to add a NOT NULL column to an existing table. Why is it happening ?. I tried rake db:reset thinking that the existing records are the problem, but even ...
35
votes
8answers
21k views
Rake just one migration
I'm trying to run just one migration out of a whole bunch in my rails app. How can I do this? I don't want to run any of the migrations before or after it. Thanks.