class Patient < ActiveRecord::Base
protected
def name=(value)
mod_name = []
value.split.each do |n|
n.split("")
type = n[0] ? "up" : "down"
n.send("#{type}case")
mod_name.push(n)
end
@name = mod_name.join
end
end
class PatientsController < ApplicationController
def create
@patient = Patient.new patient_params
@patient.save ? redirect_to(patients_path) : render(:new)
end
private
def patient_params
params.require(:patient).permit(:name)
end
end
, setter, . .
, - .
, .
, , / , .
-
- Rails - , . Ruby - , , .

, . , class (IE, ), (IE ).
"class" (Model.method
) "" (@model.method
) :
class Patient < ActiveRecord::Base
def explode
puts "Instance Explode"
end
def self.explode
puts "Exploded"
end
end
, :
@patient = Patient.find params[:id]
@patient.explode #-> "Instance explode"
Patient.explode #-> "Exploded"
-
, , , .
, , , .
...
@patient.name = params[:params][:name].name_fix
.
, .name_fix
, . .name_fix
, , , , helper
:
class PatientsHelper
def name_fix value
end
end
class PatientsController < ApplicationController
def create
@patient.name = name_fix params[:patient][:name]
end
end
.name
, name=
. , , .