ruby-on-rails-5

Big Sur Update Leads to Multiple Load Error Rails Ruby

你离开我真会死。 提交于 2021-02-20 02:53:29
问题 After updating to Big Sur, my ruby (2.6.3) on rails (5.2.1) application repeatedly has LoadError when running rails s or rails db:migrate . I have tried uninstall and reinstall rails multiple time but it will only work 1 or 2 times before encountering LoadError again. Here are some samples of the errors (Note that they are different) /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require': cannot load such file -- new_relic/agent/instrumentation

Big Sur Update Leads to Multiple Load Error Rails Ruby

◇◆丶佛笑我妖孽 提交于 2021-02-20 02:52:49
问题 After updating to Big Sur, my ruby (2.6.3) on rails (5.2.1) application repeatedly has LoadError when running rails s or rails db:migrate . I have tried uninstall and reinstall rails multiple time but it will only work 1 or 2 times before encountering LoadError again. Here are some samples of the errors (Note that they are different) /Library/Ruby/Gems/2.6.0/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require': cannot load such file -- new_relic/agent/instrumentation

Remove devise email validation

与世无争的帅哥 提交于 2021-02-11 08:10:33
问题 I use devise and devise-token-auth. I have User model with following content class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:login] include DeviseTokenAuth::Concerns::User validates_uniqueness_of :login validates_presence_of :full_name protected def email_required? puts "email_required called" false end end but devise email validation is still working 2.3.0 :003 > user = User.new

Remove devise email validation

▼魔方 西西 提交于 2021-02-11 08:05:27
问题 I use devise and devise-token-auth. I have User model with following content class User < ApplicationRecord devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :authentication_keys => [:login] include DeviseTokenAuth::Concerns::User validates_uniqueness_of :login validates_presence_of :full_name protected def email_required? puts "email_required called" false end end but devise email validation is still working 2.3.0 :003 > user = User.new

Deploy error ruby on rails Don't know how to build task 'assets:precompile'?

送分小仙女□ 提交于 2021-02-10 14:24:05
问题 I try to run on Digitalocean cap production deploy but i got this this error 00:42 deploy:assets:precompile 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile 01 rake aborted! 01 Don't know how to build task 'assets:precompile' (See the list of available tasks with rake -… 01 /home/deploy/RubyProject/shared/bundle/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in <top (requi… 01 /home/deploy/.rbenv/versions/2.6.6/bin/bundle:23:in load' 01 /home/deploy/.rbenv/versions/2.6.6/bin/bundle

Rails export multiple csv in same view

百般思念 提交于 2021-02-10 05:22:09
问题 I have two csv exports on the same view, both with different data. Currently it's just downloading the same data for both. View <%= link_to "Trials export", data_path(format: "csv") %> <%= link_to "Results export", data_path(format: "csv") %> Controller respond_to do |format| format.html format.csv { send_data @trial_data.trials_export, filename: "trials_export.csv" } format.csv { send_data @trial_data.results_export, filename: "results_export.csv" } end Model def self.trials_export csv << [

Rails 5: form_for vs form_with

烂漫一生 提交于 2021-02-08 12:33:30
问题 Rails 5 has introduced new form helper method form_with . How does it differs with form_for and when is it more appropriate to use? 回答1: This is really in preparation for rails 5.1 where only form_with should be used. It's meant to serve as a replacement for the two methods form_for and form_tag . form_for and form_tag in Rails were very similar, both allowed you to create a form tag but the first one uses model’s attributes to build create or update form, while the second one simply creates

Trix editor validation

一曲冷凌霜 提交于 2021-02-08 09:10:40
问题 Using Trix editor via Rails view helpers. = form.rich_text_area :description, class: 'form-control', placeholder: 'Description' Have some model 'required' validation for description. The normal Rails behavior of wrapping fields with field_with_errors is not happening. Has anyone managed to get Trix and the normal Rails validation behavior to work together? 回答1: Ended up fixing this way.. - if job.errors[:description].count > 0 .form-with-errors = form.rich_text_area :description, class: 'form

Rails: Switch DB Connection on Request

喜你入骨 提交于 2021-02-08 08:47:58
问题 I am running Rails5, and I have an App that I want to change the DB based on the subdomain ... using this past question/answer (which is based on Rails 3) I was able to build something that kind of works. I modified my base Model to use a custom connection handler, but it only runs on server start, not on every request. Here is my base Model & Custom Connection Handler: class CustomConnectionHandler < ActiveRecord::ConnectionAdapters::ConnectionHandler def initialize super @pools_by_subdomain

Rails 5 - save rolls back because nested models parent model is not being saved before child model

天大地大妈咪最大 提交于 2021-02-07 09:33:39
问题 Ok folks, Rails 5 has really had its nuances differing from Rails 4. What I have going on is that every time I click the submit button on the form it reloads with the error Profile user must exist and Profile user can't be blank . The form loads fine including the nested models form, but for what ever reason it is failing to save the parent model before attempting to save the child model with the following output to the console: Puma starting in single mode... * Version 3.7.0 (ruby 2.2.6-p396