ruby-on-rails-4.2

Jbuilder Rails caching is slower

早过忘川 提交于 2019-12-03 15:09:40
I've tried to use caching with collections (with multiple solutions) the problem is that when ever I try caching the response become slower consider the following example of a collection that renders 2 partials for every item in it (around 25 item) json.data do json.array! @organizations do |organization| json.partial! 'api/v1/organizations/organization', organization: organization json.partial! 'api/v1/organizations/links', organization: organization end end without caching the average response time is around ~38ms (on average) now with caching json.data do json.array! @organizations do

Why doesn't Rails autoload classes from app/services?

会有一股神秘感。 提交于 2019-12-03 09:18:02
I'm working on a Rails 4.2 app and have just added app/services/fetch_artists.rb to the structure. Inside this file, I have defined a class FetchArtists; end . When trying to run rails r 'FetchArtists' it gives me a NameError: uninitialized constant FetchArtists . I've tried looking at ActiveSupport::Dependencies.autoload_paths and indeed, app/services is not there: /.../app/assets /.../app/controllers /.../app/helpers /.../app/jobs /.../app/mailers /.../app/models /.../app/controllers/concerns /.../app/models/concerns /.../spec/mailers/previews My question is, why isn't this folder

Assets pipeline doesn't work in 'application.scss' in my Rails 4.2 app

点点圈 提交于 2019-12-02 16:09:45
问题 I'm new in Rails and apologize if that is a stupid question. But i cannot resolve my problem: I added Bootstrap to my new app but it still doesn't use any new styles. I've renamed application.css to application.scss and created such structure: |-stylesheets |-elements |--articles |---article.scss |-application.scss Application.scss /* User styles * Plugins first */ @import "bootstrap-sprockets"; @import "bootstrap"; @import "elements/**/*"; /* * This is a manifest file that'll be compiled

Assets pipeline doesn't work in 'application.scss' in my Rails 4.2 app

怎甘沉沦 提交于 2019-12-02 08:36:32
I'm new in Rails and apologize if that is a stupid question. But i cannot resolve my problem: I added Bootstrap to my new app but it still doesn't use any new styles. I've renamed application.css to application.scss and created such structure: |-stylesheets |-elements |--articles |---article.scss |-application.scss Application.scss /* User styles * Plugins first */ @import "bootstrap-sprockets"; @import "bootstrap"; @import "elements/**/*"; /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within

using has_many through with dynamic forms rails 4

元气小坏坏 提交于 2019-12-02 04:55:58
I want to create an appointment form with dynamics forms. But I'm not getting what I'm doing wrong I'm having trouble with the partial _appointment_record_form_fields and with appointment_controller. Someone can help me fix the controller and the view? My Models: class Appointment < ActiveRecord::Base has_many :appointment_record_forms, dependent: :destroy has_many :record_forms, through: :appointment_record_forms accepts_nested_attributes_for :appointment_record_forms, allow_destroy: true end class AppointmentRecordForm < ActiveRecord::Base belongs_to :appointment belongs_to :record_form

Heroku: Error pushing Rails app to Heroku, Heroku can't find Rails app

微笑、不失礼 提交于 2019-12-02 00:57:16
问题 I am attempting to push a Rails app to Heroku however I am constantly getting this error. user$ git push heroku master Initializing repository, done. Counting objects: 158, done. Delta compression using up to 4 threads. Compressing objects: 100% (144/144), done. Writing objects: 100% (158/158), 671.52 KiB | 160.00 KiB/s, done. Total 158 (delta 32), reused 0 (delta 0) -----> Ruby app detected -----> Compiling Ruby/Rails ! ! An error occurred while installing Ruby ruby-2.1.1 ! For supported

Heroku: Error pushing Rails app to Heroku, Heroku can't find Rails app

随声附和 提交于 2019-12-01 22:06:21
I am attempting to push a Rails app to Heroku however I am constantly getting this error. user$ git push heroku master Initializing repository, done. Counting objects: 158, done. Delta compression using up to 4 threads. Compressing objects: 100% (144/144), done. Writing objects: 100% (158/158), 671.52 KiB | 160.00 KiB/s, done. Total 158 (delta 32), reused 0 (delta 0) -----> Ruby app detected -----> Compiling Ruby/Rails ! ! An error occurred while installing Ruby ruby-2.1.1 ! For supported Ruby versions see https://devcenter.heroku.com/articles/ruby-support#supported-runtimes ! Note: Only the

NoMethodError - undefined method `timestamp_sort_order' for Paper trail issue after upgrading Rails 4.2

南楼画角 提交于 2019-12-01 21:26:18
问题 I used paper_trail to tracking transnational changes when I migrated rails 3.2 to rails 4.2, have got below issue: NoMethodError - undefined method `timestamp_sort_order' for 回答1: I fixed this by adding below line in intializer paper_trail.rb file PaperTrail::Rails::Engine.eager_load! See my final intializers/paper_trail.rb file PaperTrail::Rails::Engine.eager_load! module PaperTrail class Version < ActiveRecord::Base ..... end end Problem resolved.... 回答2: got this on rails 6.0.0beta3

Rails 4: Heroku + Paperclip + s3 not working in production

ぐ巨炮叔叔 提交于 2019-12-01 13:36:07
问题 so im following this tutorial: https://devcenter.heroku.com/articles/paperclip-s3 I manage to deploy it to Heroku and App is working in the development. The app is running in Heroku but when i try to upload photo. it gives me this page We're sorry, but something went wrong. I try to debug it by going to console and typing heroku logs it gives me the following error: heroku[router]: at=info method=POST path="/friends" host=s3friends.herokuapp.com request_id=4173ed9e-ed69-492c-b1b9-d98227ca678c

Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

风流意气都作罢 提交于 2019-11-30 11:30:05
In the Rails 4.1.1 version of an app, I have the following create method in articles_controller: def create @article = Article.new(article_params) authorize @article if @article.save flash[:notice] = "Successfully created article." redirect_to edit_article_path(@article) else render :new end end However, after updating to Rails 4.2 the following error occurs when the redirect is attempted: wrong number of arguments (2 for 1) Why does this error occur and how can it be resolved? The issue was caused by the Gemfile containing an outdated version of Turbolinks (2.2.2). I resolved the issue by