Data dodania Pytanie
2017-07-19 18:07 Rails: Custom ordering and priority for model »
For a Rails project I am working on, I have a model that has an image and a priority attached to it. So it looks something like this: card: -id ...
(2) odpowiedzi
2017-07-18 06:07 How do you add a custom uniqueness validation to an ActiveRecord model in Rails? »
I was perusing the Ruby on Rails Guides article on ActiveRecord validations and I came across this neat excerpt about the uniqueness validation: T...
(2) odpowiedzi
2017-07-17 05:07 How do I get the nth record for each distinct name in a table in rails? »
Essentially I want to get the nth last record for each distinct name. So if I have a table that looks something like name field1 a 1 b ...
(1) odpowiedzi
2017-07-15 06:07 How to achieve concept of connection list with minimal cost using rails ActiveRecord? »
Say User A is connected to B, then user B is automatically considered to be connected with user A. User has_many connection Connection Table: id, ...
(1) odpowiedzi
2017-07-13 01:07 Casting JSON with ActiveRecord raw query »
Is it possible to make ActiveRecord to cast JSON values from the raw queries somehow? Here's an example where I want to get {"x": 1} result to be cas...
(1) odpowiedzi
2017-07-12 17:07 How to model a doctor and patient appointments in rails? »
Rails and stackoverflow beginner here so please pardon me for any mistakes. I am developing an appointment booking system between doctors and patient...
(0) odpowiedzi
2017-07-12 05:07 rails factory rspec tests failing because of "only_integer" validation in model »
I have a factory for my model 'price' but all rspec tests start failing when I put the validation for price as only_integer. The error i get when i tr...
(1) odpowiedzi
2017-07-10 12:07 Wrong type and format validation on CarrierWave uploader field in ActiveRecord model »
I have User ActiveRecord model, with login, email, avatar string format fields. If I'm trying to save user with {login: 1, email: 1, avatar: 1} with w...
(0) odpowiedzi
2017-07-10 00:07 Order of pairs for each_cons(2) »
I have a Rails 5.1 application with the following models: class Game < ApplicationRecord has_and_belongs_to_many :players end class Player <...
(1) odpowiedzi
2017-07-08 09:07 Rails - How to load nested attributes by condition while loading parent? »
I have two models namely Invoice and InvoiceDetails. An invoice has many invoiceDetails. Now when I load an invoice, it also loads up the invoiceDeta...
(1) odpowiedzi
2017-07-07 17:07 Rails 5 using Ransack, custom scope order for sorting »
I'm using Rails 5 with Ransack, and I have a Model with a column in my Mysql db called status. Status is an integer from 0-5. I am trying to create a ...
(1) odpowiedzi
2017-07-07 00:07 Pass parameter in the select of a query »
I am building a query but I need to pass the parameters that I am sending to the model to be used in the query, the problem is that I can not make the...
(1) odpowiedzi
2017-07-07 00:07 I want to save GeoJSON polygon »
I want to save a polygon. This is Geojson enter link description here str1 = "geojson....." geom = RGeo::GeoJSON.decode(str1, json_parser: :json) l ...
(1) odpowiedzi
2017-07-06 23:07 How to use restore_attributes in a Rails controller with nested attributes? »
Example: a Person model accepts_nested_attributes_for a Pets model as in the example found here. Submitting a form_for(@person) with a nested fields_...
(1) odpowiedzi
2017-07-06 21:07 How can I encrypt a date value in Rails? »
I have char and text values encrypted in the Postgres database, but how do I encrypt a date value like DOB? Do I put it into a char format and use str...
(1) odpowiedzi
2017-07-06 17:07 Preventing inverse friendships from being created via has_many through type of relationship »
I'm creating a facebook clone for a project, and I'm having trouble preventing friendships from being created for relationships that already technical...
(0) odpowiedzi
2017-07-05 19:07 How to a second condition in a rails Active Record query »
I want to do something like SQL AND to add a second condition to this: Article .where("date_trunc('day', created_at) = ?", Date.yesterday-(params[:...
(2) odpowiedzi
2017-07-04 18:07 Creating category-subcategory model upto nth level in rails »
I want to create a model of categories with nth level subcategories. I can create upto 2 levels but could not go beyond it. class Category < Acti...
(1) odpowiedzi
2017-07-04 17:07 Rails multiple object creation with one form »
I have 4 Models in my Rails application. class Region < ApplicationRecord has_many :shops end class Shop < ApplicationRecord belongs_t...
(0) odpowiedzi
2017-07-02 13:07 Rails 5 - Validate model attribute equals one of 3 defined strings »
Still newish to Rails, so apologies, I've been looking online and can't seem to find something that works. I have an application where a guest can RS...
(1) odpowiedzi
2017-07-01 12:07 Rails - Columns pointing to same table »
I have a database with tables containers and ports. The containers table has two columns pol_id and pod_id that both point to the ports table. The po...
(1) odpowiedzi
2017-07-01 01:07 Character columns are silently truncated »
When using ActiveRecord to store a string into a SqlServer nvchar column, and the length of the string is larger than the maximum length of the column...
(2) odpowiedzi
2017-06-30 12:06 How to delete a Rails (ActiveRecord) session at the end of a request »
We use Rails with the devise and cancancan gems. Our user sessions are stored using ActiveRecord SessionStore. In our front end (JavaScript) code we...
(0) odpowiedzi
2017-06-30 08:06 Need help getting list of queries from Rails ActiveRecord »
I currently have three models: class Match < ApplicationRecord has_many :rosters, dependent: :destroy has_and_belongs_to_many :players end...
(2) odpowiedzi
2017-06-25 11:06 Why does my Rails 5 application print twice each record? »
This is a rails admin application and at the same time is an API. When I invoke myroot/api/v1/users I get twice each record. This is my User model cl...
(2) odpowiedzi
2017-06-25 10:06 ActiveRecord::AssociationTypeMismatch on STI through association »
It's gonna get a bit tricky. So, I have a forum app consisting of Section entities. And the forum also has Char entities (who write posts and create...
(0) odpowiedzi
2017-06-23 21:06 Inserting and deleting associated data in database »
I am still learning Ruby on Rails and ll of the related things so please bare with my limited knowledge. I have developed small a rails app for learni...
(1) odpowiedzi
2017-06-23 16:06 Rails 5.1 has_many through - associated fields »
(See example schema image below) I am attempting to query a single user from the users table using the email field, along with the id & key field...
(1) odpowiedzi
2017-06-22 16:06 How to update columns in ActiveRecord when saving associations? »
Is there a way in Rails 4.2 to perform a callback even when associations are saved, only once, and only when something changes? The before_save...
(0) odpowiedzi
2017-06-21 17:06 Rails: Issue in adding alias name in rails sql query »
i am working on maintenance application.basically i have a method in my code which is called by multiple methods. This method basically forms sql quer...
(1) odpowiedzi
2017-06-21 08:06 Get random records from rails 5 but keep one record(based on some value ) on top »
I have a Question table. It has a dummy question in it , i want to get the question in random but that dummmy question should always be on top in the ...
(2) odpowiedzi
2017-06-21 04:06 Retrive records count from has_many relation »
I have the following models Bookrack.rb has_many :faculties Faculty.rb belongs_to :bookrack has_many :books Book.rb belongs_to :faculty has_many :b...
(3) odpowiedzi
2017-06-20 15:06 Define a unique database model »
I'd like to create a model in my rails application that will be stored in my database (or in any other way) and which will be unique. The usual way t...
(1) odpowiedzi
2017-06-20 13:06 How to do rails migrations on existing records (historical data)? »
I have a model (Model_A) with two columns (Column_A and Column_B) My model has the following method in it, two generate value of column_B based on co...
(2) odpowiedzi
2017-06-20 11:06 How to fix an API using jsonapi-resources that is responding with mismatch type and not allowing me to create records? »
I have a problem with Mismatch types in my API everytime I want to create a new item. It happens in 2 places: when I try to POST a new item POST...
(0) odpowiedzi