Data dodania Pytanie
2017-12-06 07:12 Rails ActiveRecord Associations that include "owner" role »
I’m creating a chore tracker app as my first Rails project and I’m wondering if the associations I've created make sense or could be improved. He...
(1) odpowiedzi
2017-12-05 21:12 Delegating methods to has_many associations ignores preloaded data »
Is it possible to delegate a method to a has_many association in rails, AND still save the preloaded data on that association, all while following the...
(2) odpowiedzi
2017-12-05 15:12 Rails ActiveRecord Callbacks: Update if Exists, Create if Doesn't Exist »
After combing through the documentation I am having a difficult time understand what callback I should be using. pseudo code: if child_id and outag...
(1) odpowiedzi
2017-12-02 10:12 Search within activeRecord relation ruby on rails »
This is my controller code @users = User.all Inside view I have a drop-down from which I select a user. I want to show details of that users before...
(2) odpowiedzi
2017-12-02 06:12 Ahoy Top Events By Hash Property »
I am trying to find the proper way to get the top 5 (by count) events in a database based on a particular property in the events ("value"). I am also ...
(0) odpowiedzi
2017-12-02 03:12 Mysql error on sql like operator rails »
I get an error Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right...
(1) odpowiedzi
2017-12-01 14:12 Filtering by categories with rails »
I have 2 models Recipe and Category, they associated with has_and_belongs_to_many, now I need to filter recipes by categories, when user checks catego...
(1) odpowiedzi
2017-12-01 08:12 ActiveRecord AVG calculation »
I have request: Model.group(:p_id).pluck("AVG(desired)") => [0.77666666666666667e1, 0.431666666666666667e2, ...] but when I ran SQL SELECT AVG...
(2) odpowiedzi
2017-11-30 17:11 Complexity Class for a Wildcard MySQL Search »
I have two mysql tables. In one table is the actual data (of a product for example) and in another are tags. Each product can have an unlimited amount...
(1) odpowiedzi
2017-11-29 21:11 Rails has_many :through with namespace - uninitialized constant »
I'm having some trouble defining a has_many :through relationship in Rails 5 where the join and target models both reside within a namespace. I have a...
(1) odpowiedzi
2017-11-29 07:11 Ruby: What does binds mean in ActiveRecord gem? »
I saw binds as argument in lots of methods, but without any documentation. e.g. Rails Source code def find_by_sql(sql, binds = [], preparable: nil,...
(1) odpowiedzi
2017-11-28 23:11 Ruby, query active model dynamically »
I have an Order model in my ruby on rails application which has several attributes. I want to query those orders according to parameters given by user...
(1) odpowiedzi
2017-11-28 15:11 Rails how to get entries where we ignore deleted_at property along with other properties »
I have the model Store. I would like to check an existence of an entry in the database by Store.where(:google_place_id => 'XXXX'). I just want to c...
(3) odpowiedzi
2017-11-28 08:11 Removing all database access capability from rails 5.x client app »
I am still fairly new to ruby and Ruby on Rails framework. Rails --api only project is great for just getting into bare bones rest API development wi...
(0) odpowiedzi
2017-11-22 23:11 Understanding rails queries with named scopes and associations »
I'd like to use joins/includes queries with associations to render out some plays for a given user. I have a user, User < ApplicationRecord has_...
(0) odpowiedzi
2017-11-22 17:11 Active record group by relation and count »
I have these classes class Challenge has_many :photos end class Photo belong_to :challenge has_many :votes end class Vote belongs_to :photo...
(1) odpowiedzi
2017-11-22 00:11 Ruby On Rails ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: malformed array literal: " »
I have an entity where I defined a column to be an integer array type. int[]. I tried to do something like t = Thing.new t.numbers = [1,2,3] ...
(2) odpowiedzi
2017-11-20 23:11 Rails 5 accepts_nested_attributes_for/has_many :through »
How do I create a new model containing a reference to an association (many-to-many, using has_many :through) which already exists? Here are the relev...
(0) odpowiedzi
2017-11-20 03:11 ACTIVE Record Query to Fetch data from three associated models »
I am a newbie to programming and rails.In my Rails app, I have models called users, listings, reservations.A user has_many listings and reservations.A...
(2) odpowiedzi
2017-11-20 02:11 changing a columns data within irb for a heroku app »
I have an app on heroku which I need to alter. My app is a ruby on rails app and I am using the devise gem for sign in and the cancancan gem for auth...
(1) odpowiedzi
2017-11-19 11:11 rails model returns nilClass although it contains data »
I have a send method inside destinations_group_controller. def send @destinations_group = DestinationsGroup.all puts @destination_group.class ...
(1) odpowiedzi
2017-11-18 12:11 Rails select in non-table model »
With inspiration from https://github.com/merit-gem/merit i try to build a function that would be called with an after_action in my application_control...
(0) odpowiedzi
2017-11-16 10:11 Spree active record object nil when eager loading »
I'm trying to query item and loop through them. The li is not nil but accessing product on it throws NilClass error. Spree::LineItem.includes(:produc...
(0) odpowiedzi
2017-11-16 10:11 Adding enum on model shows error on initializing different class object »
I have added enum on RvDate model as: class RvDate < ApplicationRecord enum status: { Available: 0, Not_Available: 1 } # Associations belongs_...
(3) odpowiedzi
2017-11-14 21:11 ActiveRecord has_many with OR condition »
I'm trying to set up a has_many relationship that uses an OR query. My model: class Printing < ActiveRecord::Base has_many :content_tags, depend...
(0) odpowiedzi
2017-11-14 20:11 Group records by created_at in ActiveRecord »
I'm trying to find how many records were created on a given day, to get something like this: User uploaded 5 objects two days ago User uploaded 12 o...
(1) odpowiedzi
2017-11-14 16:11 How to query where an array column contains one or more values with Active Record? »
I have a Rails 5 application, with a PostgreSQL 9.6 database. The application has Report model, with a department_ids array field, which is defined i...
(1) odpowiedzi
2017-11-13 18:11 How to use rails ActiveRecord to perform a left join of a Model with a subquery »
I am using rails 5. When I perform the following straight SQL query in the rails console, I get the following expected result: 2.3.5 :053 > ...
(1) odpowiedzi
2017-11-13 12:11 'TypeError: can't dup NilClass' while running rake db:migrate »
akash@123-Lenovo-ideapad-110-15ISK:~/Akash/Live Projects/peatio1$ rake db:setup Output: W, [2017-11-13T17:18:12.292750 #3570] WARN -- : You are se...
(0) odpowiedzi
2017-11-12 23:11 Processing pgSQL query results in batches »
I've written the rake task to perform a postgreSQL query. The task returns an object of class Result. Here's my task: task export_products: :environ...
(1) odpowiedzi
2017-11-12 17:11 Rails query subclasses and limit one each »
I have an artifacts table that holds downloaded files. Each type holds different data. class Artifact < ActiveRecord::Base end class ForecastArt...
(1) odpowiedzi
2017-11-11 00:11 how to fetch an object by matching an array of foreign keys? »
I have 2 models: Group and User in my rails app. Group has many users. In my app, I would like to use an array of User Ids to check if a Group exi...
(1) odpowiedzi
2017-11-09 22:11 Build list of plucked attributes from belongs_to association »
Active Record ninjas, Jumping between languages I've forgotten how to do this: I'm looking for a concise Rails way to get attributes out of an associ...
(2) odpowiedzi
2017-11-09 20:11 Deactivate all the greetings except the one that was activated »
I have 4 greetings created. I want to activate one greeting at a time. When I activate one greeting, none of the other greetings should activate. How ...
(1) odpowiedzi
2017-11-07 11:11 rails rspec stubbed ActiveRecord::Relation for ActiveRecord Serialize »
can I stub ActiveRecord::Relation for ActiveRecord Serialize !? I could stub ActiveRecord::Relation .. but it doesn't work for ActiveRecord Serialize...
(0) odpowiedzi