forked from fixin.me/fixin.me
		
	Merging from main master to my repo master. #4
@ -18,9 +18,10 @@ class Default::UnitsController < ApplicationController
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def import
 | 
			
		||||
    params = @unit.slice(Unit::ATTRIBUTES - [:symbol, :base_id])
 | 
			
		||||
    current_user.units
 | 
			
		||||
      .find_or_initialize_by(symbol: @unit.symbol)
 | 
			
		||||
      .update!(base: @base, **@unit.slice(:name, :multiplier))
 | 
			
		||||
      .update!(base: @base, **params)
 | 
			
		||||
    run_and_render :index
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -58,7 +58,7 @@ class UnitsController < ApplicationController
 | 
			
		||||
  private
 | 
			
		||||
 | 
			
		||||
  def unit_params
 | 
			
		||||
    params.require(:unit).permit(:symbol, :name, :base_id, :multiplier)
 | 
			
		||||
    params.require(:unit).permit(Unit::ATTRIBUTES)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def find_unit
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,6 @@
 | 
			
		||||
class Unit < ApplicationRecord
 | 
			
		||||
  ATTRIBUTES = [:symbol, :name, :multiplier, :base_id]
 | 
			
		||||
 | 
			
		||||
  belongs_to :user, optional: true
 | 
			
		||||
  belongs_to :base, optional: true, class_name: "Unit"
 | 
			
		||||
  has_many :subunits, class_name: "Unit", dependent: :restrict_with_error, inverse_of: :base
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user