Data dodania Pytanie
2016-11-27 19:11 Select simple value in ActiveRecord »
I want to show a text summary for a model in a Rails application. Currently I'm doing it like this: class ServiceOrder < ApplicationRecord has_...
(1) odpowiedzi
2016-11-27 00:11 Undefined method 'transactions' for array when running db:seed »
I am trying to seed my database with some values. Types User, Account, and Transaction are ActiveRecord objects. Two users are created successfully an...
(1) odpowiedzi
2016-11-24 19:11 ActiveRecord select by field comparison »
I'm trying to select records where two fields do not have equal values. (where field A does not have the same value as field B). This involves alias_a...
(2) odpowiedzi
2016-11-24 13:11 'dependent: :destroy' on 'has_many :through' with 'polymorphic: true' »
Can't get dependent: :destroy to work on association through a polymorphic association. I have this associations on my model: has_many :playlist_i...
(0) odpowiedzi
2016-11-24 11:11 Rails / ActiveRecord: how to get all articles whose tags are included in current article tags? »
This one is a head scratcher! I'm trying to get all articles whose categories are included in current article's categories. What I have so far, whic...
(1) odpowiedzi
2016-11-23 10:11 Ruby on Rails - disable products category »
I'm writing a web application "online store" and I want to categories of products were not available when the cart is not the product of the previous ...
(0) odpowiedzi
2016-11-23 00:11 Postgres 9.5.3 JSON fields comparing dates with operators weird behavior on Mac OSX 10 »
I'm having a problem on both of my Mac machines, but not on my Linux machines. Using date comparison operators like this does not work on my Mac: # R...
(1) odpowiedzi
2016-11-22 23:11 Rails 5 controller before_action method not receiving form params »
I have an application that has a Venue model, each venue has many events, and each event has many sign_ups as signupable (I have another model that ha...
(1) odpowiedzi
2016-11-22 00:11 After renaming a model, why do my create and update functions fail? »
I renamed one of my models and its associated table name, controller, view folder, and references of the old name throughout all files in the app. The...
(1) odpowiedzi
2016-11-21 22:11 Applying methods in ActiveRecord query with joined tables »
I am trying to retrieve a list of clients who's last state_change has a to_state_id equal to the value of the type argument (in self.filter_by). I ha...
(1) odpowiedzi
2016-11-20 11:11 ActionView::Template::Error (PG::GroupingError: ERROR: column error rails »
When I try to use query below: @play_lists_progress.sorted_resource.quiz_attempts.select("quiz_attempts.*, SUM(score) as total_score").group("studen...
(0) odpowiedzi
2016-11-18 16:11 after_destroy not called for linked table »
I have these models class User < ActiveRecord::Base has_many :user_functions, :dependent => :destroy has_many :functions, :through => :u...
(1) odpowiedzi
2016-11-18 09:11 ensure association is created or saved after primary model has been saved and created Rails 4 »
I have these 2 models as follow class Application < ActiveRecord::Base has_many :commitments, class_name: "Commitment", \ :source => :ap...
(1) odpowiedzi
2016-11-18 03:11 How Rails resolve model attribute since they not defined in the model? »
I am started to learn Ruby and Rails, sometime the "Convention over configuration" kind of killing me... OK, I created a User model in Rails via the ...
(1) odpowiedzi
2016-11-17 22:11 Rails HABTM after_add callback fires before saving primary object »
I have two ActiveRecord models having a HABTM relationship with eachother. When I add an AccessUnit through a form that allows zones to be added by ch...
(0) odpowiedzi
2016-11-17 19:11 Rails 5 Active Record Associations »
I am learning how to work with Ruby on Rails and want to find the best way to solve my issue. I have searched through many forums and the Rails docum...
(1) odpowiedzi
2016-11-17 00:11 Force full object load with eager loading and nested objects »
My object model goes a little something like this: Order has_many line items has_many transactions has_many products through line items L...
(1) odpowiedzi
2016-11-15 22:11 Display field from hash »
I use this code to find object relation for a specific user <%= @tt = recipient.camping_ids %> => give me an ID example [75] <%= @ww = Ca...
(1) odpowiedzi
2016-11-15 19:11 Active Record Associations- One Model can belong to different models at the same time »
What is the correct way to create active record relationships for a scenario where- One instance of a Model A can belong to multiple of instances of ...
(1) odpowiedzi
2016-11-15 17:11 How to define an application wide ids with Rails 5 on PostgreSQL 9.4.8 »
I thought I had the solution here: application-wide sequence It looks like behaviour has changed since Rails 5. I define a specific sequence to handl...
(1) odpowiedzi
2016-11-14 14:11 Delete 1-to-1 association in Rails »
I have Person-has-one-Address in Rails. the has_one association is set on Person, while belongs_to is set to Address. I tried to delete this associat...
(0) odpowiedzi
2016-11-14 14:11 Rails where condition on has_and_belongs_to_many association »
I have a has_and_belongs_to_many association between product and supplier. join table is products_suppliers. I am trying to create dependent selects...
(2) odpowiedzi
2016-11-14 02:11 Rails find_by_sql - Use "?" literally rather than as bind variable? »
In the below, I want the first ? to be used literally, only the second ? should be used as the bind variable marker: Foo.find_by_sql ["select IFNULL(...
(1) odpowiedzi
2016-11-11 19:11 ActiveRecord query on dates in user's time zone »
I'm having querying objects on the same date relative to the user (ie if it is 2016-11-11 in the user's time zone, they should see events that occur o...
(1) odpowiedzi
2016-11-10 20:11 Rails Rspec allow_any_instance_of raises "does not implement" error for ActiveRecord object attributes »
I have next problem. When I try to stub instance method of ActiveRecord model with allow_any_instance_of I receive error message "Model does not imple...
(1) odpowiedzi
2016-11-10 19:11 Update boolean and create new records simutaneously - Rails »
I need to update a Boolean and also create new records at the same time. I have a controller called Bank, and Bank has 3 attributes, namely account:st...
(1) odpowiedzi
2016-11-10 07:11 Assign a value to an active record relation field »
This is my first model : class Sender < ApplicationRecord has_many :letters end and this is the Second one: class Letter < ApplicationR...
(2) odpowiedzi
2016-11-09 19:11 Query Array of Arrays Of Hashes using Postgres »
I have a model that has a column that looks like this (example): column = [{:A => "1", :B => "2"}, [a, b, c, ..., n]] Where a, b, c and n are...
(1) odpowiedzi
2016-11-08 21:11 Accessing before update value of active record object »
I have implemented a function which is called when an active record object is successfully updated, but I have to pass the before and after update val...
(1) odpowiedzi
2016-11-08 21:11 How to manually save a reference object in Rails »
Edit: Main problem was that when I added the reference fields, I did theater:reference and not theater:references so the field was not marked as a for...
(2) odpowiedzi
2016-11-06 22:11 Include nested associations in JSON »
# Person.rb class Person < ActiveRecord::Base has_many :events end # Event.rb class Event < ActiveRecord::Base belongs_to :person has_man...
(1) odpowiedzi
2016-11-06 08:11 How do I establish a relationship between two objects where both need to have many of the other object? »
My situation is this: I have two models, Model (as in car model) and Engine. I have some Models which have more than one Engine (different model years...
(1) odpowiedzi
2016-11-06 06:11 Criticism to Single Table Inheritance »
I often apply Single Table Inheritance to model classes but I found some of my colleagues are negative toward STI. They prefer "Class Table Inheritanc...
(0) odpowiedzi
2016-11-04 22:11 Chaining Activerecord functions in a chainable activerecord function »
I'm attempting to make a reusable library based off jquery-bootgrid. When jquery-bootgrid makes a request for more data - pagination, search, what ha...
(2) odpowiedzi
2016-11-04 09:11 How to prevent any changes on table between two different queries »
So lets say I have a couple of processes in my rails application that can all access the DB. Now in one of the processes I want to query a table and s...
(1) odpowiedzi