Data dodania Pytanie
2017-11-07 03:11 how should a join table controller associations be pluralized in rails »
I have a clients table and a workers table that are joined with a clients_workers table. The join table has some additional columns so I have a contro...
(2) odpowiedzi
2017-11-05 21:11 Rails 5: Add record to join table without model (has_and_belongs_to_many) »
I have a User and MeetOption table. This is a many-to-many relationship, and I was able to create a join table using the create_join_table command: r...
(1) odpowiedzi
2017-11-05 16:11 Rails as_json performance issues »
I have an array of Active model records. The array will have at max about 75 objects in it. However the model is complicated with multiple associatio...
(1) odpowiedzi
2017-11-03 11:11 Hash with array keys to simple hash of hashes »
Is there an easy way to transform the first one to the second one ? This comes from two successive ActiveRecord .group() method. 1) sales = {["USD",...
(1) odpowiedzi
2017-11-03 02:11 How do I refer to multiple join tables with the same underlying model? »
I have a model that looks like the following: class A has_many :B, -> { ... where clause 1 }, source: :tags has_many :C, -> { ... where cla...
(1) odpowiedzi
2017-11-02 05:11 Dup on ActiveRecord objects - can access child objects, but not through join »
I have the following associations: Teacher hasMany Students hasOne Desk When duping Student objects like so: @new_teacher.students = teacher.stude...
(1) odpowiedzi
2017-11-02 03:11 ActiveRecord query to retrieve child objects based on a deeply nested condition »
I have the following relationships: Teacher hasMany Students hasOne Desk I need to retrieve all Student objects, using an instance of Teacher, base...
(1) odpowiedzi
2017-11-01 19:11 How to not lost all data in production mode after database migration in development mode in Rails »
I am working on a rails app with a few git branches. we deploy the production mode using Capistrano::Rails. What currently struggling me is that I ad...
(1) odpowiedzi
2017-11-01 14:11 Maximum column difference in two successive rows »
I am working Rails app with PostgreSQL Database. I have table Named uploads, which has records like this ID media_count created_at 1 10 ...
(1) odpowiedzi
2017-10-31 18:10 Rails: Query to sort record by number except 0 »
I'm arranging the data based on a priority(ascending order), where '0' ignored in prioritising. Below is the Rails Query: Profile.where(active: true...
(1) odpowiedzi
2017-10-31 16:10 Remove similar records when iterating an ActiveRecord relation in Rails »
I would like to find the best way to remove items from an array during an iteration of ActiveRecord results. I want to remove the record from the arr...
(1) odpowiedzi
2017-10-31 04:10 Recovery id on nested routes »
I have two tables, one goal call the other day, the day belongs to the goal and each goal has many days. I'm currently in the view of the goalscontrol...
(0) odpowiedzi
2017-10-30 21:10 Smart update on active record, choose fields to update »
I have a problem that I do not know how to solve. I have a table targets, so the user creates a goal by setting the start date and end date of it auto...
(1) odpowiedzi
2017-10-30 13:10 Optimizing Multiple Queries using ActiveRecord Rails »
I have a method which currently functions correctly but I'd like to know if there's a better way of doing it. There's a queue of items (songs) where ...
(1) odpowiedzi
2017-10-30 02:10 Active record find_by_sql, object field return nil in the first time »
I run the following code in rails console: functions = Function.find_by_sql("Select * from functions where active = 1 and role_id =1") It returns:...
(0) odpowiedzi
2017-10-28 14:10 Cannot use polish letters in RoR application »
I have problem when I trying to insert object to database. Looks like it's convertion problem. Is there a way to fix this? I, [2017-10-28T14:02:19...
(1) odpowiedzi
2017-10-28 11:10 Dynamically set initial state with aasm gem »
I've an ActiveRecord model. I'd like to set an initial state depending on its attributes at the initialization. Here is my condition: self.expected_d...
(1) odpowiedzi
2017-10-27 23:10 How to create query for associated tables with OR condition for recent items? »
I have two associated tables as below. blogs table: ----------- id title body created_at modified_at comments table: --------------- id: blog_id: c...
(0) odpowiedzi
2017-10-27 22:10 How to find has many records based on search field with OR condition »
I have implemented a search which can search records from different columns but it does not work if I search records in has_many (categories) table fo...
(1) odpowiedzi
2017-10-27 05:10 how to sum one column, multiply value of another and return object activerecord »
I'm trying to find the top selling items. An Item has an id and price. It has_many ItemOrders, which belongs_to Item and has an item_id. I've tried......
(1) odpowiedzi
2017-10-26 00:10 Time zone changing arbitrarily »
I'm using the gem groupdate to do a query like this in a controller's action: Event.where.not(user_id: [1, 3]).group_by_week(:created_at, week_start...
(1) odpowiedzi
2017-10-25 22:10 Creating a Rails 5 migration for foreign key(s) referencing their own table »
I'm writing a little dog database that shows family trees. I have a postgresql table 'dogs' that has a dog_id, name, weight, etc. I also want it to ha...
(2) odpowiedzi
2017-10-25 20:10 Speeding up a active record query called in active_model_serializers »
I have a class named Product and nesting other products with the same sku attribute with active_model_serializers. The problem is that the query is r...
(0) odpowiedzi
2017-10-25 17:10 Rails error: Index name '...' on table '...' already exists while running rails db:migrate »
So I'm working with a colleague who added some additional migration files and per normal procedure once I pulled their version I ran rails db:migrate....
(3) odpowiedzi
2017-10-24 16:10 Save a record in rails, id returned is nil »
I'm trying to save a message. Some Thing like this one: if @message.save Rails.logger.info " Message 1 ++++++#{@message.try(:inspect)}" end In ...
(0) odpowiedzi
2017-10-24 00:10 Find column by value »
class Child has_many :toys end class Toys belongs_to :child end class CreateToys < ActiveRecord::Migration[5.1] def change create_table :t...
(1) odpowiedzi
2017-10-23 20:10 Is there a way to force validations on an unchanged invalid object in Rails »
Short version For some reason I can't fully pinpoint, Rails isn't updating when I add a missing field, having previously conditionally overwritten its...
(0) odpowiedzi
2017-10-23 20:10 Rails 5 - Joins null association without using join? »
What do I want What I need to get all orders without acceptance for a given user, but I'm having issues with the first part only. What do I have He...
(1) odpowiedzi
2017-10-19 17:10 Mapping ActiveRecord as dynamic key value pair on Rails »
I want to map ActiveRecord query as a key value pair I want to get the json_results in the form { "16": "2017-10-16T17:04:51.000Z" } But the below...
(2) odpowiedzi
2017-10-19 06:10 How to create form object for simple CRUD operation in rails 5? »
I have a controller which is responsible for CRUD operation on Post model. I am trying to move functionality from this controller to a form object. F...
(0) odpowiedzi
2017-10-18 15:10 Cannot access children in after_create method in Rails 5 »
In my app I have bookings and passengers where one booking has many passengers. After creating a new booking I want to send a notification to all pas...
(2) odpowiedzi
2017-10-18 14:10 Rails model design for user specific result »
I currently have two Rails models as follows: class Job < ApplicationRecord has_many :job_interests end class JobInterest < ApplicationRecor...
(1) odpowiedzi
2017-10-18 01:10 Storing time with milliseconds in Rails »
I'm trying to store a time stamp with millisecond precision in Rails, but the value gets jacked up when I retrieve the record from the DB: record.tim...
(3) odpowiedzi
2017-10-17 19:10 Why is Postgres double-quoting the first function identifier when I set a default function for a column? »
I have a legacy table with a default expression in a Rails project. This expression picks a random four-digit number and converts it to a string. Duri...
(1) odpowiedzi
2017-10-17 14:10 How to add has_many association to two different model in rails migration? »
How can i accomplish this? class User < ActiveRecord::Base has_many :old_posts has_many :new_posts end I already have has_many relation...
(1) odpowiedzi