Data dodania Pytanie
2017-02-26 08:02 create calls before_save multiple times »
I have a before_save callback in my model which encrypts 2 fields before they're saved to the database. class Account < ActiveRecord::Base befor...
(1) odpowiedzi
2017-02-25 02:02 Can i cache a parent in rails? »
I have this code: Business.all.limit(50).each do |business| card = {name: business.name, logo: business.logo, category: business.category.name} f...
(1) odpowiedzi
2017-02-24 21:02 How can I define an after_add method on the relation class instead? »
I have a Character class and a Siblingship class. To denote that one character is a "sibling" of another, I save a Siblingship instance with a charac...
(2) odpowiedzi
2017-02-24 12:02 Active Record Filter on Two Models »
I am building a reservation system where users can search for an open reservation. Reservation has an :on scope that filters the reservations that are...
(3) odpowiedzi
2017-02-24 08:02 What is ClassName::create in Rails »
I ran into is this code: run Athlete::Create do |op| return redirect_to op.model, notice: 'Athlete was successfully created.' end I'm used to the...
(2) odpowiedzi
2017-02-23 21:02 How to write into different tables when rails model has been inherited? »
I have the following models: class Building < ActiveRecord::Base;end class Department < Building;end class Organization < Building;end W...
(1) odpowiedzi
2017-02-23 09:02 Finding True value in rails »
I have a table called DueAction and it has an reference of DueEmployeeDetail.I need to update is_confimed column of DueEmployeeDetail only when all th...
(1) odpowiedzi
2017-02-23 03:02 How to write the active record query »
I have three models in context of this question: class ClearanceBatch < ActiveRecord::Base has_many :items belongs_to :user end class...
(1) odpowiedzi
2017-02-22 18:02 Bulk modify ActiveRecords based on condition in Rails 5 »
I have a model Posts with a column author_id ´, also I have a logged in user with a user_id I am listing all Posts with: posts = Post.all In this...
(1) odpowiedzi
2017-02-22 05:02 remove_reference and down migration of add_reference reports no foreign key »
Migrating up this migration def change remove_reference :order_items, :order, foreign_key: true end or migrating down this migration def chang...
(1) odpowiedzi
2017-02-22 00:02 ActiveRecord: Can successfully query with .where(foo: "bar") but .where.not(foo: "bar") doesn't return the correct results »
I have a query built like so: @events = current_organization.events.order(started_at: :asc) I would like query all those events where the status is...
(2) odpowiedzi
2017-02-21 04:02 Does Rails Really Cache Database Query? »
Does Rails actually cache the query result? The documentation says that same query will be never executed twice on the same request: 1.7 SQL Cachi...
(1) odpowiedzi
2017-02-17 13:02 Rails multiple joins condition query for exact tags with has many through relationships »
I have a problem with filtering products by exact tags as my current query does not return exact matches and I can't seem to get the right query condi...
(1) odpowiedzi
2017-02-17 06:02 ArgumentError when storing point using RGeo »
I'm having some trouble storing a point in RGeo. initializer/rgeo.rb RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config| # By default...
(0) odpowiedzi
2017-02-16 20:02 How to save 'Yes' or 'No' instead of 'true' or 'false' with Rails check_box form helper? »
I have an object @recipient with attribute responding. Say, I want responding to store "Yes" or "No" via =f.check_box :responding, {}, 'Yes', 'No', wh...
(2) odpowiedzi
2017-02-16 00:02 How to order records by created_at last 3 days first, then by another column, using rails [Postgresql] »
Using Active Record, How to order by 2 columns (created_at, views): 1st: the records created within the last 3 days 2nd: everything after that shoul...
(2) odpowiedzi
2017-02-15 18:02 Rails 5 includes and polymorphic »
I'm using Rails 5 and try to do next class Song has_and_belongs_to_many :artists end class UnknownSong end class Library belongs_to :media, pol...
(0) odpowiedzi
2017-02-15 15:02 It is possible to use the new ActiveRecord::Attributes API in a PORO? »
I usually include ActiveModel::Model into some PORO (for example for a FormObject::SignUp). I've read about the new Rails 5 ActiveRecord::Attribute A...
(2) odpowiedzi
2017-02-15 13:02 Automating pairing in ruby on rails database »
I have a site where users can register and view thgeir profile with their data showing.. I created two columns paid which is boolean(default: false) a...
(0) odpowiedzi
2017-02-14 11:02 Rails version migration issue (Rails 4.2 to 5.0) »
When migrating from rails 4.2.6 to 5.0.1, I am getting some errors: undefined method `push' for #<User::ActiveRecord_Relation: while doing: @us...
(2) odpowiedzi
2017-02-14 10:02 How to filter the array of records per model name ruby on rails »
Suppose I have hashes of elements and I need to filter out the results based on the class names in them. so, if records contains elements of PrivateS...
(2) odpowiedzi
2017-02-14 05:02 How to find records where a column value = [given array] in rails »
Setup: Rails + Postgres. I have table A with columns id: int, name: string, address: string, s_array: varchar[], i_array: int[], created_at: dateti...
(3) odpowiedzi
2017-02-13 01:02 Rails 5 Query when using both single and multiple association relationships »
I have a rails app with the following setup: class Organization < ApplicationRecord has_many :user_orgs has_many :users, :through => :u...
(1) odpowiedzi
2017-02-12 22:02 Active Record where join table record doesn't exist »
I am trying to get a list of all records that don't exist in a join table. The models are User, Game and MarkedGame, where users can mark games as pl...
(2) odpowiedzi
2017-02-12 08:02 Ransack - Acts as Taggable On - Not tagged query - Error »
I am making a search form with Ransack to query a resource with the presence or not presence of a tag. For example, if I want a tag Archived, I will ...
(0) odpowiedzi
2017-02-12 04:02 Change model attribute name based on status? »
I have a Match model that has 3 users: an observer, a player1, and a player2, and a status enum (which could be finished or pending). When the Match ...
(2) odpowiedzi
2017-02-11 04:02 How to find number of records based on association through join table »
I have User, Assignment, and Account models. Users can belong to many accounts and accounts have many assignments. As an admin on an account you can '...
(2) odpowiedzi
2017-02-10 14:02 Rails - how to incorporate 'quantity' bookings using counter_cache and update correctly »
I'm building an events app using Rails and have added a counter_cache association between my Event and Booking models in order to capture the number o...
(1) odpowiedzi
2017-02-09 14:02 Rails - counter_cache not working »
I'm building an events app using Rails and have added a counter_cache association between my Event and Booking models in order to capture the number o...
(1) odpowiedzi
2017-02-09 10:02 find_or_create_by trying to create duplicate records with hmt association »
I'm curious if there is another way of achieving the following. Setup: class Cabin < ApplicationRecord has_many :feature_groupings has_many ...
(1) odpowiedzi
2017-02-08 22:02 Multiple LIKE and AND operators in RAILS/POSTGRESQL »
I'm using Rails 5.0.1 and Postgresql as my database. I have a table with column :content which contains words. The problem: When I'm looking for a sp...
(3) odpowiedzi
2017-02-08 18:02 Rails has and belongs to many duplicate entries »
I have 2 models and a join table('email_addresses_mailable_events'). Database being used is Postgres. class MailableEvent < ApplicationRecord ...
(0) odpowiedzi
2017-02-07 00:02 Why would updates to a paper_trail-enabled model fail silently? »
Rails 5.0.0, Heroku Postgres 9.6.1 m = MyModel.create(foo: 'bar') => #<MyModel foo: 'bar'> m.foo = nil => nil m.save => true m.reload ...
(0) odpowiedzi
2017-02-06 22:02 CRUDL - Accessing ROR item with parameter other than id »
I am designing a Web API and a local database for devices to use. These databases sometimes communicate. Because items in each database have different...
(1) odpowiedzi
2017-02-05 12:02 Have CKeditor use custom model »
I am trying to create a setup where only one table is used for files including ckeditor. As it stands I am using the default with table that is genera...
(1) odpowiedzi