Data dodania Pytanie
2018-02-15 22:02 Reinserted deleted record in rails using the console »
I have a record which I deleted and now I need to reinsert it with the same id as before. I have the whole object saved. Is there a way I can directly...
(1) odpowiedzi
2018-02-14 20:02 Rails 5 select from two different tables and get one result »
I have 3 models, Shop, Client, Product. A shop has many clients, and a shop has many products. Then I have 2 extra models, one is ShopClient, that g...
(4) odpowiedzi
2018-02-14 13:02 Search columns affected after csv download in Rails »
We currently have an issue in which, after downloading a CSV file, when reloading the page, we get an error. While diving in, I found out that it's be...
(1) odpowiedzi
2018-02-13 13:02 Delete Record in Sinatra »
I am having some trouble implementing a Delete route into Sinatra with Active Record. Here are the code details Route delete '/contacts/:id' do @c...
(3) odpowiedzi
2018-02-10 06:02 Why Rails i18n doesn't look up under activerecord.attributes? »
Versions: 2.3.4 :011 > RUBY_VERSION => "2.3.4" 2.3.4 :012 > Rails::VERSION::STRING => "4.1.8" Backends: 2.3.4 :013 > I18n.backend...
(0) odpowiedzi
2018-02-09 20:02 Correct way to build multiple belongs_to association »
I've a rails table such as: class CreateContent < ActiveRecord::Migration def change create_table :contents do |t| t.references :data_...
(1) odpowiedzi
2018-02-09 02:02 How can I "bump" posts by ones with the latest comments AND have new posts with no comments appear at the top in Rails? »
For example: I want a post just submitted to appear at the top of the page. Then if someone comments on an older post, I'd now like this at the top. ...
(3) odpowiedzi
2018-02-08 01:02 Select different table fields »
I use rails 4 and mysql. I have two Recipe and Category models. class Category < ApplicationRecord has_many :recipes validates_uniqueness_of :...
(3) odpowiedzi
2018-02-07 20:02 Optimizing delete operations in Rails 4 / ActiveRecord / MySQL »
Essentially, we need to delete T1 records that have not had a t3 record associated with it for given @user. Though not required, it would be nice to d...
(1) odpowiedzi
2018-02-05 15:02 Relationship model between users, companies and introductions »
Apologies for the newbie question but I am completely stumped on this one. I have two models, user and company, and I am trying to establish a "reque...
(1) odpowiedzi
2018-02-02 19:02 Change value in DB of associated model through Devise »
I am using Devise for users, and I have another model called “Host Requests” that allows users to submit an application for different access level...
(1) odpowiedzi
2018-02-02 11:02 How to return the most recent children unique by parent with ActiveRecord »
A post has_many comments. A comment belongs_to a post. I'm trying to get back a list of the most recent comments, but only one per post. The followin...
(1) odpowiedzi
2018-01-31 12:01 How to query an STI-driven model using nested associations? »
My requirement is to write a query to retrieve records based of a model on STI based on the nested associations of the model. Here’s what my model...
(1) odpowiedzi
2018-01-30 20:01 Rails5.0.2 enum handling invalid values »
I have a Work model that includes a status enum type enum status: { beginning: 0, middle: 1, end: 2 } Upon creating a new Work record, there could ...
(0) odpowiedzi
2018-01-29 11:01 Simpleform, create two nested models at once »
I have two models that are nested, a Project has a name and a Budget, and a Budget has an amount and belongs to a Project. I got a form page where I ...
(2) odpowiedzi
2018-01-29 08:01 Rails associtating three models »
I have the following models in my rails application class User < ApplicationRecord end class Group < ApplicationRecord end class Role < Ap...
(4) odpowiedzi
2018-01-28 13:01 Multiple-level join condition in ActiveRecord »
I'm struggling to set a condition on a multiple-level join in my Rails ActiveRecord query: class CourseSlot < ApplicationRecord belongs_to :co...
(1) odpowiedzi
2018-01-26 19:01 ActiveRecord Query Not Returning »
I have a query in my Rails application that should return a specific user (I've triple-checked, the user passes all of the variables), but it instead ...
(5) odpowiedzi
2018-01-26 12:01 Simpleform with two models not nested but linked, failing to submit »
For the moment I've got two models in my app. class Budget < ApplicationRecord belongs_to :project end class Project < ApplicationRecord ...
(1) odpowiedzi
2018-01-25 19:01 Rails: eager-loading on an already-left-joined table? »
We are already left-joining a table so that we can order by a column, if the relation exists: people = Person .joins("LEFT JOIN addresses ON addres...
(0) odpowiedzi
2018-01-24 22:01 Memoization & caching in Ruby & Ruby on Rails »
Given application is looping through many fields Why is Application making multiple SQL calls even if I memoize the object or Given application i...
(1) odpowiedzi
2018-01-24 17:01 Refactor compare diff of active record logs from two different code paths »
I'm looking to refactor a major part of a codebase and in order to have high confidence in the changes, one thing I am looking to do is log and diff a...
(0) odpowiedzi
2018-01-23 00:01 Update attributes without touching the database in Rails »
I have a situation where I have an ActiveRecord::Relation object, where the relation's objects have some has_many associations. There is another piece...
(2) odpowiedzi
2018-01-22 00:01 Ruby on Rails ActiveRecord query select only column string field value with where clause? »
I was wondering if there is a way to use a select statement with a where clause similar to this way that does not seem to work for me in Ruby version ...
(2) odpowiedzi
2018-01-20 08:01 Rails get sum of field grouped by using includes »
I have the following models class Application has_one :referral has_one :detail end class Referral belongs_to :application belongs_to :status...
(1) odpowiedzi
2018-01-19 23:01 Differences between `any?` and `exists?` in Ruby on Rails? »
In Ruby on Rails, there appear to be two methods to check whether a collection has any elements in it. Namely, they are ActiveRecord::FinderMethods’...
(2) odpowiedzi
2018-01-19 00:01 Rails: as_json ignoring parameter »
I'm trying to make a "not simple" query using ActiveRecord: ChatRoom.first.as_json(include: { chat_room_members: { include:{ ...
(1) odpowiedzi
2018-01-18 22:01 Access to model instance up the where chain in Rails »
Is it possible to, within the record found through an association, retain access to the related model instance which found it? Example: class Person...
(1) odpowiedzi
2018-01-18 22:01 Pricing plans and custom discounts for some users »
I have Users and Plans in my app. We want to create custom discounts on a user per user basis. I thought that my SpecialDiscount model should belong...
(1) odpowiedzi
2018-01-18 02:01 Deserialized Rails ActiveRecord object won't save to SQL database »
Problem: After serializing and deserializing an object, a perfectly valid ActiveRecord model object will not save to SQL database. The objects are se...
(1) odpowiedzi
2018-01-17 19:01 Rails 3.2.25 upgrade to 4.0.0 - "uninitialized constant ActiveRecord" on all active record queries »
Im in the middle of performing an edge ruby and rails update for a web app built in rails 2.3.18 and running ruby 1.9.3. I have been incrementally be...
(0) odpowiedzi
2018-01-16 04:01 rails inverse of a scope »
Is there a method to negate the result of a scope? I have 3 models, associated by has_many :through association user.rb class User < ActiveRecord...
(1) odpowiedzi
2018-01-15 17:01 Nested ActiveRecord access »
I am trying to access nested ActiveRecord data in my Rails Project. I want to acces all Devices in all Subnets of a single user I would like to do som...
(2) odpowiedzi
2018-01-14 14:01 Ruby on Rails 5.1 from helper_method can not get Data in View »
I am new in RoR and i am using helper_method to pass data from ActiveRecord. My code is follow: class ApplicationController < ActionController::B...
(1) odpowiedzi
2018-01-10 07:01 remove foreign_key in Rails 5 has_many »
In attempting to build a materialized path model hierarchy (as detailed here), I wanted to figure out how to solve the N+1 problem the other describes...
(0) odpowiedzi