-
replace
after_filterandbefore_filterwithafter_actionandbefore_actioncallbacks.after_filterandbefore_filterare both deprecated in rails 5 -
Rails 5 stops some raw SQL and prevents SQL injections. For raw SQL there will be warning (error in rails 6) so we should change raw SQL string literals to Arel objects Arel.sql('')
-
:conditionno longer an acceptable key (replace withwhere):orderis no longer an optionhas_many :order(block):uniqis no longer an optionhas_many (replace with -> { distinct }) -
Rails 5: ActionController::Parameters Now Returns an Object Instead of a Hash Address the article
undefined method `to_sym' for #<ActionController::Parameters:0x00005613f2464c20>To resolve try two ways:
# 1
def permitted_params
params.permit!
end
# 2
# replace with your model name
def customer_params
params.require(:customer).permit(
# list of params
)
end-
error
undefined method where_clauses
Ransack changes
meta_search gem deprecated and replaced with Ransack
search_methods method no longer exists. Purpose is to make the scope accessible by ransack search. Adding custom method > ransackable_scopes so that the scopes can be whitelisted and used. Also need to replace form_for with search_form_for
Refactor the sort_by_direction methods (ok for now but we can use ransack sort with custom ransackable_scopes
EX. REPLACE sort_by_directions :sold_units_repairs_complete, "inspection_completion_date is not null and intake_completion_date is not null"
WITH scope :sort_by_sold_units_repairs_complete_asc, lambda { order(Arel.sql("inspection_completion_date is not null and intake_completion_date is not null ASC")) } scope :sort_by_sold_units_repairs_complete_desc, lambda { order(Arel.sql("inspection_completion_date is not null and intake_completion_date is not null DESC")) }
- Replace
= hidden_field_tag 'search[meta_sort]', @search.meta_sortwith
= hidden_field_tag :s, value: params[:q].try(:[], :s)- here is an example of the scope I mentioned...they will no longer be needed
scope :created_at_gteq, ->(date) { where("vehicles.created_at >= ?", date) }
scope :created_at_lteq, ->(date) { where("vehicles.created_at <= ?", date) }- There is a new controller concern with name
Ransackable. It turn on by adding a line in the controller you working on:inlcude Ransackable
Replace:
# Replase this
search = params[:search] || {}
search[:meta_sort] ||= "stock.desc"
# with this style
search = q_param # use q_param method from the concern
search[:s] ||= "stock desc" # replace meta_sort with s in ransackEnumerize changes
- In
Prodmodule may occur smth likeundefined method _reflect_on_association.
belongs_to :productionreplace with
belongs_to :production, class_name: '::Production'get__valueswas part of symbolize gem...for enumerize we no longer needget_and_valuesis now.valuesUPD: probably even is now.optionsi.e.
Vehicle.get_inventory_type_values # Symbolize version <----- Replase this
Vehicle.inventory_type.value # Enumerize version. <----- with thisuninitialized constant Production::EbayMotors
# replace
Production::EbayMotors
# with
Prod::Production::EbayMotors- Replace
methodswithpredicatesfor generate boolean methods by collection keys
# Symbolize version <----- Replase this
enumerize :status, :in => STATUSES.keys, :methods => true, :default => :in_progress, :allow_blank => true
# Enumerize version. <----- with this
enumerize :status, in: STATUSES.keys, default: :in_progress, allow_blank: true, predicates: true- error
NotImplementedError (input should be implemented by classes inheriting from CollectionInput)can be resolved by adding a method in a class of input with issue.
def input
input_html_options[:type] ||= input_type
end- error
No valid predicate for ftx_search... in progress...