Tagged Questions
0
votes
0answers
15 views
Ruby on Rails : Development vs Production database - where to enter data?
I'm very new to Rails.
I am confused about the development and production databases. I am using postgreSQL for all of my environments and heroku to host the site. I am able to push migrations and ...
1
vote
2answers
40 views
Ruby on rails - wrong number of arguments (2 for 1) [Rails]
I've just change my database from sqlite3 to postgresql in my Ruby on rails.
Every things worked before but now I have a "wrong number of arguments (2 for 1)" when I submit the form. I don't ...
0
votes
1answer
22 views
Rails handle multiple Params in search query
I have the following model and I want to pass multiple params in "with_query", don't know how to achieve it. currently you can see it takes only "query" param. how can I filter it with country and ...
0
votes
1answer
30 views
Rails lost migration file issue
2 months ago, one of my migration files has been removed. The thing is when I rake db:migrate my database in localhost the migration is missing. I can Not create a new migration because the production ...
1
vote
5answers
62 views
<% if current_user.id == @status.user_id %> when user not signed in
Currently, I have in my 'show' view for a question model
<% if current_user.id == @question.user_id %>
<%= link_to 'Edit', edit_question_path(@question) %>
<% else ...
0
votes
2answers
21 views
Postgress error- bundle install
When I run $bundle install I am running the project on heroku so I had to switch to postgress. I keep getting this error for some reason. An error occurred while installing pg (0.15.1), and Bundler ...
0
votes
4answers
27 views
getting a random product in rails
/products/index.html.erb
<div class="hide-for-small panel">
<h3>Sidebar</h3>
<h5 class="subheader">Feature Product</h5>
<% Product.random do | product | %>
...
0
votes
1answer
34 views
sqlite vs postgreql in rails
Quick questions, haven't been able to find concrete answers about this questions. I'm guessing it's because the answer is obvious.
I know that in order to push a rails app to Heroku a postgreql ...
0
votes
1answer
14 views
Capistrano, Rails, PostgreSQL Master-slaves replications making it hard to add additional tables to slaves
I have build a document-management system which consist of a content-management Rails application (for writing and managing docs, users and other content) and an End-User Rails application (for ...
0
votes
1answer
23 views
How to describe a column programmatically in select part of request in Rails?
There is the following scope:
scope :by_radius, ->(lat, lng, rad) { select("*, (6371 * acos(cos(radians(#{lat})) * cos(radians(latitude)) * cos(radians(longitude) - radians(#{lng})) + ...
0
votes
1answer
21 views
Cannot install pg gem in Mavericks with Postgres.app
I am trying to install the pg gem for use with Postgres.app on my local machine. I am running Mavericks.
Postgres.app is installed and running fine, but I cannot get the gem to work. I've done the ...
0
votes
2answers
27 views
Ruby on rails : Data base sqlite3 to PostgreSQL [RALS]
I'm converting my data base from sqlite3 to PostgreSQL in my rails project, so I follow this tutorial : https://devcenter.heroku.com/articles/sqlite3
I suceed to make all the needed changes but at ...
0
votes
1answer
14 views
postgresql full text search rails title and description
I am trying to search a model with title and description, but having the following error. I want to be able to search title and description and the type of job. Any help will be really appreciated.
...
0
votes
0answers
6 views
Rails cache digests and multple schemas
We are looking at using the cache digest gem in our Rails 3 application. One area of concern is the fact that we are using multiple schemas. Does anyone know if we will need to add the schema/tenant ...
0
votes
2answers
35 views
postgresql rails price range filter with between
I have the following array of price ranges how can I perform a query to find the price range between these using and operator
This is the array I have
["0-1000", "5001_15000", "15001_25000"]
...
0
votes
1answer
16 views
Sunspot only can search one column in table
I can search the customer by name.
But can not search any data with phone and email.
Is there something wrong?
controller
@customer = Customer.search do |q|
ap(params[:customer_query])
...
2
votes
1answer
39 views
Data type of attribute on join model in Active Record/Rails 3.2/PostgreSQL database
I have models Client and Sessions and a join model ClientSessionAssignment that associates the two. ClientSessionAssignment has one join column score which is defined as decimal type in schema.rb. I'm ...
0
votes
1answer
30 views
Rails in production mode does not connect to second database
I am using rails 3.2.15. I have two postgresql databases one of them main and the other postgis. From model Postgis I make connection to postgis database like this:
class Postgis < ...
1
vote
2answers
34 views
Active Record object based on group by count
Hi I am ROR developer and using rails 3.2.13 with Postgres database.
I have two models:
Question
attr_accessible :category, :is_active, :question_text, :question_type_id, :survey_id,
...
0
votes
3answers
39 views
Equivalent of strftime in Postgres
After migrating my SQLite database to Postgres on the development server, I get the
PG::UndefinedFunction: ERROR: function strftime(unknown, date) does not exist
Is there a function I could use ...
-2
votes
0answers
25 views
Visual bug when displaying my data
when i rendering my data from a postgres database sometimes i discover weird records in my list of cities. When i add record to my list, this bush move totaly random to another record from cities ...
0
votes
0answers
22 views
Error while running rails app on console
I'm landing up in some error when I try to run the application on the console, FYI this error is showing up on the client server, the error is
root@host [path]# RAILS_ENV=development ruby ...
3
votes
1answer
24 views
Trying to set prices to extended decimal/BTC in Rails on Heroku
So I'm relatively new to Rails, but have been trying to build a little store to sell some things for bitcoin. When I run my storefront on my local environment my pricing looks great (i.e. a book for ...
2
votes
1answer
20 views
Prepared statements in ruby/rails with postgres
I want to execute a rather nasty recursive update query in rails. This means I want to write some raw postgres sql, with parameters, and execute it inside a rails controller.
How do I do that? I ...
-2
votes
4answers
41 views
Password authentication failing for Postgresql
I'm creating a Rails app and using a Postgresql database with it. I've created a few tables and a user, core, which is the owner of each of the tables.
postgres=# create user core with password ...
0
votes
0answers
24 views
postgresql upgrade to latest version
I have the postgresql-9.2
Now I am trying to upgrade postgresql to 9.3. Since it is in live server I am unable to upgrade without proper guidance
I heard about pg_upgrade to upgrade but How can i ...
0
votes
0answers
16 views
How to fetch Heroku database and import it into a project on Amazon EC2?
On Heroku is PostgreSQL database, on EC2 MySQL.
I downloaded database from Heroku through the addon called pgbackups, but when I open the downloaded file, the output is like
5047 444d 5001 0c00 0408 ...
-1
votes
0answers
27 views
Reverse engineering radio buttons with multiple options and its sub-values
I need to reverse engineer below field in Rails. I've tried various methods like saving into another string column then reference this from types table with belongs_to relationship. This doesn't seem ...
0
votes
1answer
17 views
Rails Query Includes acts_as_votable
I'm trying to Query for top casts (kind of like posts) based on how many votes they got.
Acts_as_votable gem, and currently my casts are votable. I can vote on them and retrieve their upvotes - ...
0
votes
2answers
27 views
Postgres error when trying to display all items through a relationship
This works on SQLite3, but not on PostgreSQL.
The error I'm getting is PG::InvalidColumnReference: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
I'm trying to display ...
1
vote
1answer
21 views
Restore PG local database from SQLite DB - Rails
I just switched my whole app's (dev and test) databases to Postgres and got it working well. I did have a ton of information (users, posts, etc) on my local sqlite database that I would love to ...
1
vote
1answer
39 views
Is there a way to execute SQL functions directly using rails dbconsole
When you fire up rails dbconsole you can easily execute commands such as:
select * from users limit 1;
However some commands require using Postgres functions such as now() or timezone(zone, ...
0
votes
0answers
30 views
Rails how to implement hierarchical associations
Is there a Rails way to implement hierarchical associations?
I'm currently trying to map below layout fields in database:
Product -> Product URL -> No Link
-> ...
0
votes
1answer
14 views
Rails select register from the previous day
I'm trying to get the model instances with one day of history. I'm using postgresSQL.
What i want is likeness this:
element = Element.find(:first , :conditions => ["name LIKE ? AND created_at ...
1
vote
1answer
18 views
How to prevent concurrent requests from sneaking by a check in Rails?
User has a balance of 1.
Two concurrent requests to make a transfer worth of 1 come in the following manner:
Transfer A passes validations as the user has enough balance
Transfer B passes ...
0
votes
1answer
26 views
How do you make simple_form timezone have values which are valid for postgres
In SimpleForm you can create a timezone input:
= simple_form_for @user do |f|
= f.input :time_zone, label: 'My time zone'
However the values which simple form puts into the form are not valid for ...
0
votes
3answers
28 views
Use index to label results in rails 4
I have generated a list of files that different users have uploaded.
2 Pen writing 83746__braffe2__pen-writing.wav audio/wav 1057836 2013-11-17 03:43:29 UTC
3 Pen writing ...
1
vote
3answers
46 views
Chain an additional order on a Rails activerecord query?
Activerecord seems to ignore my second order in a chained AR query.
What I'm trying to do is retrieve the top 5 most-read articles within the top 25 highest-scored (eg. rated by users) articles.
...
1
vote
2answers
33 views
How to make ORM (ActiveRecord) Models for union queries in Rails
I have an application that has some basic entities
Posts
posts have:
Likes
Comments
and Ratings
I then have an SQL view to query for all three. With that I have a model called something like ...
0
votes
0answers
40 views
Postgres database has no password - can't get into pgadmin
I have a rails app using postgres. When I made the app, I never created a password. In my database.yml file, no password is listed. My application works, but I am trying to connect to the db using ...
0
votes
1answer
15 views
namespaced model + postgresql issue
Have a problem with PostgreSQL and a namespaced model that I don't understand.
@photos = Profile::Photo.where(:attachable_id => id)
This throws an:
!! #<ActiveRecord::StatementInvalid: ...
0
votes
1answer
48 views
Rake db:migrate and db:create not operated with proper database files
I know this question has come up on stackoverflow before, and I have tried the various solutions suggested, even trying to restart my current app. But none of them worked. I am trying to change my ...
1
vote
1answer
46 views
Rails 4 Postgresql array data-type: updating values
I am just starting to use the array data-type in Postgres with Rails 4 but I am having trouble getting values on an existing array to update. I have a column called 'quantity' that is an array of ...
1
vote
2answers
55 views
Couldn't create database when migrating to postgresql
I'm trying to deploy on heroku a simple blog I created with RoR for learning purposes and sqlite3 is not supported so I decided to migrate to PostgreSQL.
I changed my database.yml file
development:
...
0
votes
2answers
38 views
Rails mistakenly saying to add postgres to bundle
I have a rails project that uses mysql (and has so successfully in the past). However, after upgrading my postgres installation, this rails project is throwing the adapter not installed error:
...
1
vote
1answer
24 views
Select subset of elements and their children in rails
I have a collection of albums and each album has songs.
I want to filter all albums where most played songs are and inside these albums have references only to the most played songs.
Something ...
0
votes
1answer
29 views
Postgres/Rails => is object guaranteed to be persisted if I do .save?
If I have a model and save it like this:
model = Website.new
model.attr = 1
model.id = 1
model.save #assume no errors in saving
then retrieve it like this:
model2 = Website.find(1)
Will model2 ...
0
votes
2answers
56 views
how to set up postgres database for local rails project
I recently got a new machine and would now like to work on my projects from github. I'm curious as to how to properly set up the postgres database on my local machine. I have postgresql, pgadmin3 and ...
1
vote
1answer
27 views
Postgres insert error in ActiveRecord
For some reason, I cannot get ActiveRecord to correctly format the insert statement when using an array type column. It seems to want to escape the Postgres notation:
{"val1", "val2", "val3"} into ...
0
votes
0answers
26 views
Rails 3.2.13 - Heroku Error Code H10, after importing Postgres database from development environment
I created a Rails 3.2.13 app in the development environment, and as I pushed to Heroku to the production environment I got an error.
I transferred my local development PostgreSQL database over to the ...