Data dodania Pytanie
2017-04-21 22:04 Rails advanced Active Record query »
I want to do an advanced Active Record query on my models through a join and count all the records. I don't know whether it's possible to do what I wa...
(2) odpowiedzi
2017-04-21 17:04 Join Two Result Sets in Rails 4 »
How do you perform a left outer join on two ActiveRecord::Relation results in rails? Given: sales = DailySaleItem.joins(:daily_sale).where("daily_sa...
(0) odpowiedzi
2017-04-21 09:04 Unpermitted parameter when trying to update record »
I have two models, ProjectCategory and ProjectQuestion. A ProjectCategory can have many questions related to it, and a ProjectQuestion can only have o...
(1) odpowiedzi
2017-04-20 15:04 More than one enum value for an attribute »
Suppose I have the following very simple code snippet enum role: [ :admin, :enginier, :medic, :user ] I want one of my users to have the role of [:a...
(1) odpowiedzi
2017-04-19 02:04 Rails undefined method `name' for nil:NilClass and I don't get why »
Hi guys I am developing a system I created on RoR My idea is that a person can attend to serveral events, So I have 3 tables: Person, event, and atte...
(2) odpowiedzi
2017-04-17 11:04 Apply validations on attribute when a function with same name exists »
chats Schema: create_table "chats", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.integer "chat_type", limit: 2, ...
(1) odpowiedzi
2017-04-15 23:04 Type Casting a Column to bigint in Padrino Active Record »
I have upgraded to the latest Ruby on a Padrino application and I am having errors with active record when creating a new object. It's validating a nu...
(1) odpowiedzi
2017-04-15 19:04 How do I create/register a User model that has a belongs_to relation? »
I want the user to confirm their email before they add/edit their profile (it's a really big profile). On the POST /users(.:format) devise/regist...
(1) odpowiedzi
2017-04-15 10:04 Creating a nested model instance (has_many relation) on the view of its parent model »
I have a model A und a model B and the relation is A has_many B (and B belongs_to A). I have a model, a controller and views for A and only a model fo...
(1) odpowiedzi
2017-04-12 04:04 A better way to get ActiveRecord table's primary tables(belongs_to' tables) array »
I have a table with many fields [ [ 0] "id", [ 1] "type", [ 2] "title", [ 3] "delivery_fee", [ 4] "price", [ 5] "starting_pri...
(1) odpowiedzi
2017-04-11 22:04 QUERY: where has_many association does not contain specific value »
I have two models Invoice and InvoiceEvent Invoice has many InvoiceEvents InvoiceEvent has a field state I'd like to write a query to find all Invo...
(1) odpowiedzi
2017-04-11 10:04 Rails STI associations and nested attributes »
I have a structure like the following: class Order < ApplicationRecord end class BulkOrder < Order has_many :vehicles, inverse_of: :order ...
(1) odpowiedzi
2017-04-09 04:04 composite primary key not updating after save »
Here is a minimal test case that forms the basis of my question. Why is it that even though user is properly saved, the attribute user.id isn't update...
(1) odpowiedzi
2017-04-07 10:04 Rails association query based on condition »
class ConferenceSession < ActiveRecord::Base has_many :conference_sessions end class ConferenceSession < ActiveRecord::Base belongs_to ...
(2) odpowiedzi
2017-04-06 16:04 How i group the result according to 2.degree association in activerecord »
I am trying to group blog_post that is related to category. category is related to category_group. So there is no organic bond between blog_post and c...
(0) odpowiedzi
2017-04-04 19:04 SQL in AR searching if an element is not within a column array »
date = Date.today Subscription.joins(:cart).where("'#{date.beginning_of_week(:sunday).to_s}' != ANY (carts.skipped_weeks)") The column skipped_week...
(2) odpowiedzi
2017-04-03 23:04 Rails 5 Race Condition with auto_increment column and background worker »
In a Rails 5 app I have a rake task collecting all users which have to be billed today, invoking an activejob which calls a service object to actually...
(0) odpowiedzi
2017-03-31 22:03 Rails Custom Validation Across multiple attributes »
I have a rails app with the following user models: Truck User A truck belongs to a user with the following association: class Unit < ActiveRecor...
(1) odpowiedzi
2017-03-31 21:03 activerecord model with 2 parent levels »
A user can have many questions. Many users can participate on a question and provide multiple answers to the same question. Relation between users and...
(1) odpowiedzi
2017-03-30 17:03 Sanitize raw SQL with ActiveRecord »
I'm trying to get the following request sanitized to send to a MySQL server: INSERT INTO `table` SELECT NULL, t.`id`, ?, ? FROM `table` AS t ...
(0) odpowiedzi
2017-03-28 17:03 Select sum and dynamic where statement query in Rails 4 »
I have this below statement in my controller and I want to know how to rewrite it in Rails 4 Entry.find(:all, :conditions => [@conditions.keys.joi...
(2) odpowiedzi
2017-03-27 20:03 has_many :through is only working in one direction »
I have the following has_many :through situation: class User < ApplicationRecord has_many :term_enrollments, foreign_key: 'builder_id' has_man...
(1) odpowiedzi
2017-03-25 22:03 Rails Database Query ROR »
First of all, I am still new to ROR and I am trying to come up with more efficient way to do a database query for my datatables. My Model association...
(1) odpowiedzi
2017-03-23 23:03 Is there a way in rails to make a model optionally belong to another model? »
I am building a rails exercise app that has both exercises and routines. I want each routine to be composed of several exercises (has_many :exercises)...
(2) odpowiedzi
2017-03-22 16:03 rocketpants cache expose data »
In Rocketpants, you expose data to clients through expose method. Like expose competition, methods: [ :goals ] Since expose met...
(0) odpowiedzi
2017-03-22 15:03 Can you use the JDBC adapter on MRI ruby »
We're dealing with OCI issues with MRI Ruby and would like to use the gem activerecord-jdbc-adapter to simplify the process. Is it possible to use JD...
(1) odpowiedzi
2017-03-22 14:03 Rails 5 pluck alias_attribute not work on Activerecord_Relation »
I have got Rails 5 application which use mariadb. This database is configured to read table from another MSSQL database using MariaDB Connect Engine. ...
(0) odpowiedzi
2017-03-21 17:03 Alternative to using 'order' within an array »
I've been doing some edits to an output when working with some records and i've ran into a problem where the sorting option no longer is working. In...
(3) odpowiedzi
2017-03-21 10:03 Edit rails form dynamically through select tag »
I have a providers Table generated with Scaffold & have filled in the names (text_fields) of all the providers. now im trying to edit them dynamic...
(0) odpowiedzi
2017-03-20 23:03 How do I specify this `WHERE` condition without using SQL? »
I'm using the following raw Postgres SQL in my where() call to find records where some_date is two days from now: SomeModel.where('date(some_date) - ...
(1) odpowiedzi
2017-03-18 23:03 How do I update a postgres boolean field using Active Record in Rails 5? »
I created a join table like so: class CreateJoinTablePurchaseUser < ActiveRecord::Migration[5.0] def change create_join_table :purchases, :u...
(1) odpowiedzi
2017-03-16 21:03 .last method working weirdly rails »
I have an Model named Page class Page < ApplicationRecord has_many :details, dependent: :destroy end and Detail class Detail < Application...
(0) odpowiedzi
2017-03-15 22:03 Rails Query Active Record By Pairs OR'ed »
I have an API that looks like... get(not_unique_id:, pairs: []) ...where pairs can look like [{ foo: 1, bar: 'a' }, { foo: 2, bar: 'b' }] and I wan...
(1) odpowiedzi
2017-03-15 19:03 Rails: Include Model based on column value »
Consider the pseudo models: Product id type - enumerable 'book' or 'magazine' Book ...attributes Magazine ...attributes Whe...
(2) odpowiedzi
2017-03-15 18:03 How can I simulate `OR` conditions for `has_many` association in Rails 5? »
I want to simulate OR conditions for has_many association so I do not lose active record association. I understand this can be achieved using scope or...
(1) odpowiedzi