Data dodania Pytanie
2017-06-18 23:06 Rails Postgres: set all fields in a table to zero, except for »
I have a number of tables in which I set all fields to zero, except for a few select ones (including foreign keys and some time values), on a weekly b...
(1) odpowiedzi
2017-06-17 23:06 Rails 5. How to search in associated models? »
So I have 2 models: City and Country. City belongs_to Country, you know how it works. How to find Country when I'm putting City name into search field...
(2) odpowiedzi
2017-06-16 15:06 Active Record multiple selects in one query »
What ActiveRecord do I write to make this happen: SELECT COUNT(*), SUM(`users`.`sign_in_count`), MAX(`users`.`sign_in_count`) FROM `users` WHERE (`us...
(1) odpowiedzi
2017-06-15 09:06 Update with original value »
I have a Bank model with attributes id, name, code and rate. I just changed the rate method of bank model. But the problem is when I am updating the b...
(0) odpowiedzi
2017-06-13 21:06 Polymorphic has many though with STI in rails »
I've faced unusual situation with rails association and created simple sample to show that. Assume we have 4 models: 1) list.rb class List < App...
(1) odpowiedzi
2017-06-13 10:06 Editing existing record creates duplicate Rails 5 »
I had just been having problems with creating new records as posted here Can't create new record via form in Rails 5 app, so not sure if this coul...
(3) odpowiedzi
2017-06-12 16:06 Many-to-many User and Company association with multiple user 'groups' »
I'm having a bit of trouble wrapping my head around this. My goal is to create a relationship like this: Companies can have many Users (team members...
(2) odpowiedzi
2017-06-11 22:06 Rails query with Countries gem »
I have a model: Car. Each car belongs to a Museum and each museum is in a particular country. The country is stored as a two-character country code. ...
(1) odpowiedzi
2017-06-11 00:06 Create ActiveRecord has_one through association »
Given the ActiveRecord models and associations below, I need to add a has_one :owner association on the account model to reference a user whose accoun...
(1) odpowiedzi
2017-06-09 18:06 How to fetch record from deep nested association? »
I'm just starting up with RoR so bare with me if I call things wrong. I have these 3 models for example. Board, Truck, Driver. Here's a sketch of wh...
(3) odpowiedzi
2017-06-08 18:06 How to associate two joining models in ActiveRecord? »
Lets assume we have 2 AR models: class User < ApplicationRecord has_many :proposals has_many :concerns end class Job < ApplicationRecord ...
(1) odpowiedzi
2017-06-07 23:06 Is there a cleaner way to get a hold of an ActiveRecord query interface? »
I have this which works, but I thought there might be a specific method for it. @deals = Deal.where("1=1") if @dealFilter.min.to_i > 0 @de...
(1) odpowiedzi
2017-06-07 07:06 Rails 3.2 : Duplicate entry for key index in mysql? »
I am using rails 3.2. Here! I am facing a problem, stats below. I am having two model classes RequestedTrip and TagTrip. Here! are two other models R...
(1) odpowiedzi
2017-06-07 03:06 Unexpected behavior while in Rails console »
Rails 3.2 I am in a Rails console session, and I am trying to find a company by id. I have a companies tables, with an id column. I did company = C...
(1) odpowiedzi
2017-06-06 16:06 Rails 5: Associated relation triggers create instead of update on edit view »
I started with the guide on http://guides.rubyonrails.org/getting_started.html. I successfully get it up and running. So far I made a few adjustments ...
(1) odpowiedzi
2017-06-06 13:06 How can I disable lazy loading of active record queries? »
I want to query some objects from the database using a WHERE clause similar to the following: @monuments = Monument.where("... lots of SQL ...").lim...
(2) odpowiedzi
2017-06-06 04:06 How do I create a foreign key in rails 5 if I've already created the models for the tables I want to associate? »
All of the references I've found either show me how to do it upon table creation, or are for a much earlier version of rails. Ideally, I'd like like t...
(1) odpowiedzi
2017-06-05 23:06 AR Query for jsonb attribute column »
I'm using Postgres for my db, and I have a column in my Auction model as a jsonb column. I want to create a query that searches the Auction's json col...
(2) odpowiedzi
2017-06-05 19:06 Rails: destroy_all and update has_many size »
I have the following relationship: class Match has_many :players end In one example case, I have a match with 2 players, one with the attribute t...
(1) odpowiedzi
2017-06-05 18:06 Getting activerecord readonly error when adding a where clause »
I have two queries for two different pages: all_teams = Team.includes(:terms, :labs, people: [:schools], term_enrollments: [:lab]) current_teams = Te...
(1) odpowiedzi
2017-05-31 16:05 Ruby on Rails active record - understanding code »
I am very new in coding and Ruby on Rails. There is a website and the part of code below makes the data to be displayed on the website. I need to unde...
(0) odpowiedzi
2017-05-31 08:05 Can I get/access a form_builder.object's ATTRIBUTE in Rails? »
I have resorted to ask a question here since this is something that's puzzling me: I am trying to create a nested attributes form with the following ...
(0) odpowiedzi
2017-05-31 02:05 Renamed belongs_to association, it currently can't find the associated model »
My user.location is returning nil currently. My model looks like: # id # user_location_id class User < ApplicationRecord belongs_to :location, ...
(1) odpowiedzi
2017-05-30 14:05 RubyonRails Not able to save has_many relation »
I have two models industry_matcher and staffroom Model IndustryMatcher class IndustryMatcher < ActiveRecord::Base has_many :industries, cla...
(1) odpowiedzi
2017-05-26 18:05 No route matches [DELETE] "/questions/5/answers" »
Trying to create a delete button, but having some issues with the path. I thought I wrote it correct. Any help and suggestions is well appreciated ...
(2) odpowiedzi
2017-05-26 11:05 Difference between Model.ids and Model.select(:id).map(&:id) »
I have been trying to find the how rails handles call to Model.ids and Model.select(:id).map(&:id) When i try to execute the same in console i se...
(1) odpowiedzi
2017-05-26 04:05 How to perform model validation in rails? »
I have a rails application where Activity is one of the resources with the following attributes: status (recording the status of activity "in progre...
(1) odpowiedzi
2017-05-25 21:05 How can I load Rails fixtures into a different schema »
My Rails 5.0.2 application uses two databases. One is my main application database and the second is accessed in read only mode by my application (a ...
(0) odpowiedzi
2017-05-25 13:05 RoR - Show model linked with a foreign key »
In my app I have Users and Bands. A User can create a Band, so in the database schema, the table Band has a foreign key band_manager_id referred to th...
(1) odpowiedzi
2017-05-25 06:05 How do I implement a common validation method for several attributes in rails »
I have a model with two time attributes as follows, class Notification < ActiveRecord::Base validate :time1_must_be_in_the_past? validate :tim...
(2) odpowiedzi
2017-05-23 21:05 active_recrod_delayed_job is being ignored »
i have used `active_record_delayed_job' before without problem. i added to Gemfile gem 'delayed_job_active_record' rails g delayed_job:active_rec...
(0) odpowiedzi
2017-05-22 16:05 Should I use a denormaized field for amount outstanding in Ruby on Rails »
I have a simple normalized model for invoices and payments. The relevant fields are invoices.id invoices.amount_with_tax invoice_payments.id invo...
(1) odpowiedzi
2017-05-21 17:05 ActiveRecord::StatementInvalid in Controller when using an ActiveRecord with a table name and a postgresql view »
I have an Event which belongs to Repeat and I am trying to display the repeat title when displaying an event. But I do not want two database calls whi...
(1) odpowiedzi
2017-05-21 16:05 Rails: find attachments without user OR without comment »
Attachment has_one :comment, optional: true Attachment has_one :user, through :comment, comment - through task, task - through project I want to fin...
(1) odpowiedzi
2017-05-21 06:05 Is it possible that I can add and remove objects to a ActiveRecordRelation »
I have a situation where I need to concatenate multiple scopes based on time to a single active record relation. I have following model class Featu...
(0) odpowiedzi