Data dodania Pytanie
2016-12-22 10:12 Why I get `ActiveRecord::NoDatabaseError: Unknown database` error when trying to use numbers and underline in database name? »
I am using ruby-2.2.4, Rails 4.2.5 and MySQL 5.7.16 with gem mysql2 in my Ruby on Rails application. I have created database with name 123_4 and set d...
(1) odpowiedzi
2016-12-22 06:12 Rails threads hang in ActiveRecord database call when using Puma server »
I'm new to Rails and trying to code an implementation where web service queries are run in parallel using celluloid-pmap in Puma. In doing that Rails ...
(0) odpowiedzi
2016-12-21 19:12 Nested Join query enum values show up as integers in its json representation »
When doing a select of a nested association enum value and changing it to its json representation these values wont convert to strings, any other simp...
(0) odpowiedzi
2016-12-21 09:12 rails model will not populate attribute on create, fails non-null db test »
trying to create an api_key for my user. have setup so its non-null. rails 4, not -null is triggered, but i am creating the access_token item before...
(1) odpowiedzi
2016-12-21 01:12 How to Write Efficient Active Record Queries »
I am relatively new to ActiveRecord, which I use alongside Sinatra. Currently, I am building small scale websites. I have not run into any issues with...
(1) odpowiedzi
2016-12-20 15:12 How to handle 'Unclosed quotation mark after the character string' in Ruby? »
I'm getting an error when trying to grab html from a webpage and saving it to my active record object. The message I'm getting is, Unclosed quotation...
(1) odpowiedzi
2016-12-20 15:12 Custom model name in Rails 4 validation »
I have a class that looks something like this: class OrganicBipedalLifeform < ActiveRecord::Base # Has the field 'name' validate :presence_of...
(2) odpowiedzi
2016-12-19 23:12 NameError, uninitialized constant »
I'm trying to submit a simple form using rails. class BibliographiesController < ApplicationController def creer #this has been localized for ...
(1) odpowiedzi
2016-12-19 04:12 Rails/Ruby... 50mb string performance »
I'm trying to send 1mm rows worth of data to the browser. Unfortunately this is a situation where I can't use pagination. The actual raw PG query ta...
(3) odpowiedzi
2016-12-19 00:12 undefined method `request' for true:TrueClass »
I have an app structure with nested routes in which a proposal belongs to a request and a request has many proposals. When I execute a send_proposal ...
(1) odpowiedzi
2016-12-18 06:12 how to delete not saved data but i have assigned this data with build or new in rails? »
I have assigned record like this profile_image = current_user.profile_images.build(params_profile_image) But I don't want to save this record any ...
(1) odpowiedzi
2016-12-16 15:12 How to select all records having an attachment? »
I'm using rails4 with paperclip. On one of my forms I would like to list only the records of a resource having a paperclips attachment. Is there any ...
(1) odpowiedzi
2016-12-16 12:12 Using foreign_key in rails associations has_many »
Could somebody explain me is my code correct. I'm trying to get foreign_key option in rails associations. I have 2 models: Book and Author Book db ...
(1) odpowiedzi
2016-12-16 01:12 Which find gives better performance in Rails, Child.find(child_id) or parent.children.find(child_id)? »
I have 2 models. For the purpose of this Q&A I call them Parent and Child. # Parent.rb class Parent < ApplicationRecord has_many :children, ...
(2) odpowiedzi
2016-12-15 13:12 unable to insert data using custom action by belongs with has many relationship rails »
My relationships are: class PrivateClass < ActiveRecord::Base has_many :lesson_plans end class LessonPlan < ActiveRecord::Base belongs_to...
(1) odpowiedzi
2016-12-15 11:12 Why HABTM relation entries are not cleared after a destroy in Rails? »
I was wondering why I have to write this (following) code to clear the relation table after destroying one of the two elements joined in a HABTM relat...
(0) odpowiedzi
2016-12-13 11:12 Rails: Filter nested attribute in scope »
My models have the following relation: Building has many Rooms that have many Beds that have many Accommodations, and I want to render all Buildings...
(2) odpowiedzi
2016-12-12 22:12 Rails 5: (Object doesn't support #inspect) when serializing text column »
I'm building a rails 5 api only app, working with a postgres database created from a rails 4 app. In rails 4, I could easily include serialize :colum...
(0) odpowiedzi
2016-12-12 01:12 AR with sqlite3: Does setting limits on columns have any effect on db size? »
Im a bit new to AR and Sqlite. I'm working with a big dataset and struggle to figure out what's good practice for optimizing db speed and size. Eg. ...
(1) odpowiedzi
2016-12-09 09:12 Rails 5 Return all records and include necessary association »
So we have such case (many to many through): class Company < ActiveRecord::Base has_many :contracts has_many :subscribers, through: :con...
(1) odpowiedzi
2016-12-09 00:12 How to display both a link and link name from a database using rails 4 »
I would like to display a link from the database and also the link name also saved in the db.I am using rails 4 and haml. Any ideas how I can achieve ...
(4) odpowiedzi
2016-12-08 17:12 Rails 4 nested has_many with where clauses along the way »
The relationship is as follows. Client -> has_many :analytics Client -> has_many :metrics, through: :analytics Analytic -> has_many :metrics...
(1) odpowiedzi
2016-12-08 03:12 Too many checks for empty params. How to optimize queries to ActiveRecord in Rails5? »
I'm doing checks for empty parameters before do the query. There is only 1 check for params[:car_model_id]. I can imagine if I will add more checks fo...
(1) odpowiedzi
2016-12-07 19:12 Using Paranoia gem, set deleted_by user attribute with callbacks or in controller »
I am using the paranoia gem on Rails 3.2.19 (old I know, will be moving to Rails 4 at some point). My goal is to not only soft delete objects, but al...
(0) odpowiedzi
2016-12-07 17:12 Sort users based on most recent response to a particular answer in a survey? »
I'm trying to sort users based on their most recent response to a certain question in a survey using Rails 5, PostgeSQL 9.4.5 So far I've got: User....
(1) odpowiedzi
2016-12-07 15:12 Does ActiveRecord make a new database connection per model »
I'm trying to understand how ActiveRecord connects to a database on a per model basis. So lets assume we have 2 models and one database. When you do a...
(1) odpowiedzi
2016-12-06 21:12 Rails ActiveRecord Includes with Inner Join »
When doing using includes on an ActiveRecord model, is there a better way to specify an inner join then: User.includes(:address).joins(:address) It...
(0) odpowiedzi
2016-12-06 02:12 Where I should put a complex sql on a rails project? »
I would like to know what is the best way to keep in maintenance and call a complex query due to using Active Record is not a good practice to call st...
(0) odpowiedzi
2016-12-05 07:12 What is the conceptual difference between User.first.followers.count and User.first.followers.to_a.count? »
The two Active Record queries: User.first.followers.count and User.first.followers.to_a.count evaluate to the following SQL queries respectively: [4]...
(0) odpowiedzi
2016-12-03 22:12 Update a Rails model with AJAX »
I'm barely just starting to learn AJAX. My current ajax function doesn't seem to be having any effect. Here is the function from my coffeescript file...
(1) odpowiedzi
2016-12-03 16:12 join tables in RoR »
I have the following two models. class ResponseMap < ActiveRecord::Base has_many :response, foreign_key: 'map_id', dependent: :destroy belongs_to ...
(3) odpowiedzi
2016-12-02 18:12 Rails scopes downcase before searching »
I'm trying to create a scope to search the model in a case insensitive way. scope :services_offered, -> (service) { joins(:my_services).where(my_s...
(1) odpowiedzi
2016-12-01 20:12 Rails computation on large table »
I'll try to explain my problem. I've created a table which represents something like text model for the user(user_models) based on purchases. I have a...
(2) odpowiedzi
2016-12-01 08:12 Shopify Restore Deleted product »
I am working on application which interact to Shopify::API.I want to remove unnecessary (Quite OLD) product.It i will run ShopifyAPI::Product.delete(I...
(1) odpowiedzi
2016-12-01 00:12 Reference joining row in a has_many :though association »
I have a common has_many :through association between three tables and I would like to be able to either request to include the joining row as it's ow...
(0) odpowiedzi