Data dodania Pytanie
2017-01-11 23:01 How do I merge parent array and one child with different attribute? »
I have comments and likes (acts_as_votable gem). I want to create one activity list and sort by created_at for comments and updated_at for votes. @ac...
(1) odpowiedzi
2017-01-10 22:01 ActiveRecord Rollback when trying to save to database »
I am building a fairly simple album review application. I am attempting to set up a simple_form for new reviews. The change will not stick. This is wh...
(1) odpowiedzi
2017-01-10 16:01 Ruby on Rails - where query with Time parse »
How can I select all records where the date is past? I have "Date" column with format : '%m/%d/%Y' e.g "01/10/2017". Column type is string, I can't c...
(3) odpowiedzi
2017-01-09 23:01 ActiveRecord read replica for reporting queries »
I have a Rails/ActiveRecord application that occasionally executes some heavy read-only queries against the application's models for ad-hoc admin/repo...
(0) odpowiedzi
2017-01-06 13:01 How to create migration script for has_many, belong_to association between user and task model in ruby »
I have two model User and Task. Task would have one owner and other as workers. class Task < ApplicationRecord belongs_to :user has_many :...
(1) odpowiedzi
2017-01-06 00:01 rails controller find record with no associations »
Student has_many enrollments Is there a way to see only students that have no enrollments? Something like: @students = Student.includes(:enrollmen...
(1) odpowiedzi
2017-01-05 23:01 Rails Active Record Query joins only, any »
Student has_many :enrollments With this query I see those students that have true enrollments, but also those that have both, true and false enrollm...
(1) odpowiedzi
2017-01-05 05:01 Have access to multiple databases »
I am developing an application that at the beginning the user can select which database to connect to. It is a Rails application which uses Active-Rec...
(0) odpowiedzi
2017-01-04 20:01 List the number of records that have X number of associations in has_many »
I have my Person class which will have 0 or more widgets associated class Person < ActiveRecord::Base has_many :widgets end I'd like to list o...
(2) odpowiedzi
2017-01-04 14:01 Querying hstore with exists? »
I have a column as postgres hstore, and want to query it with exists? in my model. I am using Model.where("column ? :key", key: "xxx").count but ...
(1) odpowiedzi
2017-01-04 13:01 has_many relationship using FactoryGirl »
I'm trying to create instance with has_many relationship using FactoryGirl factories and fail. I have two classes: Computers and NetworkCards. Each Co...
(2) odpowiedzi
2017-01-03 22:01 Passenger Ignoring RAILS_ENV »
Background I've got an env file with various variables depended upon by my Rails app, including RAILS_ENV, which is initialized to development in thi...
(1) odpowiedzi
2017-01-03 16:01 Optional where in Rails »
How can I make a where optional in Rails? I tried: @pages = Page .where(status: params[:status].present? ? params[:status] : 1) ...
(2) odpowiedzi
2017-01-03 00:01 how to count on unique records of public_activity actions in rails? »
I am using public_activity gem. @num = PublicActivity::Activity.where(owner_id: current_user.id, key: "micropost.read").count This would show corre...
(1) odpowiedzi
2017-01-01 22:01 Sort list of objects according to an array (Rails) »
I have an array if ids from a table e.g: b = [659, 658, 656, 645, 644, 657, 634, 643, 649, 650, 651, 636, 633, 607, 605, 604, 648, 647, 675, 674, 667...
(3) odpowiedzi
2016-12-31 21:12 NOT NULL constraint failed created_at when saving model »
I'm getting an exception when I call save! in a model. SQLite3::ConstraintException at /contacts/import_spreadsheet/1/import NOT NULL constraint...
(0) odpowiedzi
2016-12-30 17:12 Use Rails' select() to add (not overwrite) selected attributes? »
I have a convenience scope that includes related models to speed up rendering of tables, etc: class Post < ApplicationRecord ... scope :inclu...
(1) odpowiedzi
2016-12-29 15:12 Model's attributes are being failed validation when they are not passed »
Is it logical that when I don't pass attributes' values, they failed the validation of the custom validation method, even though I am not trying to up...
(0) odpowiedzi
2016-12-28 18:12 Rails 5 belongs_to default behavior »
begin require "bundler/inline" rescue LoadError => e $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler" rai...
(1) odpowiedzi
2016-12-28 18:12 ActiveRecord Complex Query »
I need some advice on how I should be going about some business logic in our app. Currently I have a loop for returning all of a user’s sales opport...
(0) odpowiedzi
2016-12-28 13:12 Rails: How to show items only if creator is unique? »
I have many users and each user has multiple projects. Now, I want to get only one item per user. @projects = Project.all.where(user_id is unique) ...
(2) odpowiedzi
2016-12-26 19:12 Rails join on user column »
I'm trying to get all Activities related to users of the same school (a string on the user object), but the error I'm getting is this: Can't join...
(1) odpowiedzi
2016-12-26 08:12 Rails prints the query result along with the object data in the view »
I want to create a notebook app in rails. I need to print all the notes in the index view, so below is code in haml. = @notes.each do |note| %h1=...
(1) odpowiedzi
2016-12-24 20:12 Storing Google Maps geo data with Rails / PostGIS / RGeo »
Having trouble implementing Daniel Azuma's solution for handling Google Maps geo data with RGeo / Rails. SETUP locations table: create_table "locat...
(1) odpowiedzi
2016-12-23 21:12 What does force_reload mean? »
In ActiveRecord, when an object is given a belongs_to class method, it gains access to the #other instance method, where other is the classname that w...
(1) odpowiedzi
2016-12-23 02:12 Rails 4.2 rendering an Array in js.erb results in a crash »
So, I'm trying to render an Array of objects in my js.erb file. My controller method that's make the array looks like below: def process_report sta...
(2) odpowiedzi
2016-12-22 16:12 Logging raw SQL errors in Rake Tasks »
I'm using raw sql bulk updates (for performance reasons) in the context of a rake task. Something like the following: update_sql = Book.connection.ex...
(1) odpowiedzi
2016-12-22 10:12 Why I get `ActiveRecord::NoDatabaseError: Unknown database` error when trying to use numbers and underline in database name? »
I am using ruby-2.2.4, Rails 4.2.5 and MySQL 5.7.16 with gem mysql2 in my Ruby on Rails application. I have created database with name 123_4 and set d...
(1) odpowiedzi
2016-12-22 06:12 Rails threads hang in ActiveRecord database call when using Puma server »
I'm new to Rails and trying to code an implementation where web service queries are run in parallel using celluloid-pmap in Puma. In doing that Rails ...
(0) odpowiedzi
2016-12-21 19:12 Nested Join query enum values show up as integers in its json representation »
When doing a select of a nested association enum value and changing it to its json representation these values wont convert to strings, any other simp...
(0) odpowiedzi
2016-12-21 09:12 rails model will not populate attribute on create, fails non-null db test »
trying to create an api_key for my user. have setup so its non-null. rails 4, not -null is triggered, but i am creating the access_token item before...
(1) odpowiedzi
2016-12-21 01:12 How to Write Efficient Active Record Queries »
I am relatively new to ActiveRecord, which I use alongside Sinatra. Currently, I am building small scale websites. I have not run into any issues with...
(1) odpowiedzi
2016-12-20 15:12 How to handle 'Unclosed quotation mark after the character string' in Ruby? »
I'm getting an error when trying to grab html from a webpage and saving it to my active record object. The message I'm getting is, Unclosed quotation...
(1) odpowiedzi
2016-12-20 15:12 Custom model name in Rails 4 validation »
I have a class that looks something like this: class OrganicBipedalLifeform < ActiveRecord::Base # Has the field 'name' validate :presence_of...
(2) odpowiedzi
2016-12-19 23:12 NameError, uninitialized constant »
I'm trying to submit a simple form using rails. class BibliographiesController < ApplicationController def creer #this has been localized for ...
(1) odpowiedzi