{"id":155215,"date":"2012-10-18T13:49:04","date_gmt":"2012-10-18T09:49:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=155215"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=155215","title":{"rendered":"<span class=\"post_title\">\u0423\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Rails 3<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0438\u0445(\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445) \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438.<br \/>  <a href=\"https:\/\/github.com\/kconrails\/safe_attributes_example\"><img decoding=\"async\" src=\"http:\/\/kconrails.files.wordpress.com\/2010\/11\/download3.png?w=450\"\/><\/a><br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443 \u0432\u0430\u0441 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 Ruby on Rails. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &#8216;class&#8217; \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446. \u0420\u0435\u043b\u044c\u0441\u0430\u043c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u042d\u0442\u043e \u043a\u0430\u043a \u0442\u0435\u0449\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0442\u0432\u043e\u044f \u043d\u043e\u0432\u0430\u044f \u043f\u0440\u0438\u0447\u0435\u0441\u043a\u0430, \u0438 \u043e\u043d\u0430 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.   <\/p>\n<blockquote><p>\u0412 \u0432\u0438\u0434\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u0440\u0430\u043c\u0430\u0442\u0443\u0440\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0430\u043b\u0430\u043d\u0442\u0430, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a \u043d\u0435 \u0441\u043c\u043e\u0433, \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044f\u0440\u043a\u0443\u044e \u043c\u0435\u0442\u0430\u0444\u043e\u0440\u0443, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0443\u044e \u043e\u0431\u0449\u0443\u044e \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044e, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u043d\u043e\u0439  <\/p><\/blockquote>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"ruby\"># \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u043e\u0445\u043e-\u043e\u0431\u043e\u0437\u0432\u0430\u043d\u043d\u044b\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442  ruby-1.9.2-p0 &gt; u = User.new :class =&gt; '1995' NoMethodError: undefined method `columns_hash' for nil:NilClass <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"ruby\">#\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443, \u0432\u0438\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u043d \u0440\u043e\u0434\u0438\u043b\u0441\u044f \u043d\u0435 \u0432 \u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435.  ruby-1.9.2-p0 &gt; u = User.new :name NoMethodError: undefined method `has_key?' for nil:NilClass <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"ruby\"># \u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e  ruby-1.9.2-p0 &gt; u = User.new  =&gt; #&lt;User id: nil, name: nil, class: nil, created_at: nil, updated_at: nil&gt;   ruby-1.9.2-p0 &gt; u.class = '1995' NoMethodError: undefined method `private_method_defined?' for nil:NilClass <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0438 \u0432\u044b\u0448\u0435\u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u0430\u044f \u0442\u0435\u0449\u0430, \u0432\u0430\u0448\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043d\u0435\u0438\u0437\u0431\u0435\u0436\u043d\u044b, \u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u0447\u0435\u0441\u043a\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430.<br \/>  \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0411\u0440\u0430\u0439\u0430\u043d \u0414\u0436\u043e\u043d\u0441 \u0440\u0435\u0448\u0438\u043b \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0434\u043b\u044f \u043d\u0430\u0441 \u0441 \u0435\u0433\u043e gem <a href=\"https:\/\/github.com\/bjones\/safe_attributes\">safe_attributes<\/a>. Rails \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0430\u0446\u0435\u0441\u0441\u043e\u0440\u044b ( \u0433\u0435\u0442\u0442\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u044b ) \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 ActiveRecord. \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0420\u0435\u043b\u044c\u0441\u0430\u043c\u0438 \u0432\u0430\u0436\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0442\u0430\u043a\u0438\u0445, \u043a\u0430\u043a \u00abclass\u00bb \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430\u043c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. Safe_attributes \u0438\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043b\u044e\u0431\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0441 \u043e\u043f\u0430\u0441\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438.<\/p>\n<p>  \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"ruby\"># app\/models\/user.rb  class User &lt; ActiveRecord::Base   bad_attribute_names :class end <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f gem-\u0430 \u0432 bundle, \u043f\u0435\u0440\u0435\u0434\u0430\u0439\u0442\u0435 \u0432 bad_attribute_names \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043c\u0435\u043d \u043f\u043e\u043b\u0435\u0439 \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0435\u043b\u0435\u0439, \u0438 \u044d\u0442\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c Rails \u043e\u0442 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b-\u0430\u0446\u0435\u0441\u0441\u043e\u0440\u044b \u0434\u043b\u044f \u043d\u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043d\u043e \u0431\u0435\u0437 \u044d\u0442\u0438\u0445 \u0430\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\/\u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u0430\u0448 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 :class:  <\/p>\n<pre><code class=\"ruby\">ruby-1.9.2-p0 &gt; u = User.new  =&gt; #&lt;User id: nil, name: nil, class: nil, created_at: nil, updated_at: nil&gt;  ruby-1.9.2-p0 &gt; u.class = '1995'  =&gt; &quot;1995&quot; ruby-1.9.2-p0 &gt; u  =&gt; #&lt;User id: nil, name: nil, class: &quot;1995&quot;, created_at: nil, updated_at: nil&gt;  ruby-1.9.2-p0 &gt; u.class  =&gt; User(id: integer, name: string, class: string, created_at: datetime, updated_at: datetime)  <\/code><\/pre>\n<p>  \u0421\u0435\u0442\u0442\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 (\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u044e, \u0447\u0442\u043e \u043e\u043d \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0435\u0449\u0435 \u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435 \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u0435\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0432\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 &#8216;class&#8217;=), \u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u043e \u0432\u0435\u0440\u043d\u043e. \u041d\u043e \u0432\u044b\u0437\u043e\u0432 \u0433\u0435\u0442\u0442\u0435\u0440\u0430 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u2026 \u043d\u0443, \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e.<\/p>\n<p>  \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 hash (\u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0434\u0430\u043b\u0435\u0435 \u0445\u044d\u0448, \u043f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a\u0430). \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u0445\u044d\u0448 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043b\u044e\u0447\/\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043c\u0435\u043d\u044f\u0442\u044c.<br \/>  \u0422\u0430\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u0430\u043a new, create, update_attribute, update_attributes \u0438 \u0442.\u0434. \u0431\u0443\u0434\u0443\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 (\u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430), \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.  <\/p>\n<pre><code class=\"ruby\">ruby-1.9.2-p0 &gt; u[:class] = '1996'  =&gt; &quot;1996&quot; ruby-1.9.2-p0 &gt; u  =&gt; #&lt;User id: nil, name: nil, class: &quot;1996&quot;, created_at: nil, updated_at: nil&gt;  <\/code><\/pre>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435, \u0432\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0432\u043c\u0435\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u043b\u044c\u0441\u0430\u043c\u0438 \u0430\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u0432. \u041d\u043e \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0448\u0430\u0433\u0435 \u043e\u0442 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u041c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u044d\u0442\u043e\u043c\u0443 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0443, \u043a\u0430\u043a \u043a \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c, \u0430 \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043d\u0430\u0441 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 (\u0433\u0435\u0442\u0442\u0435\u0440\u043e\u0432 \u0438 \u0441\u0435\u0442\u0442\u0435\u0440\u043e\u0432). \u041e\u0434\u043d\u0430 \u0438\u0437 \u043f\u0440\u0438\u0447\u0438\u043d \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430.<\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0430\u0446\u0435\u0441\u0441\u043e\u0440\u044b, \u043a\u0430\u043a \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435:  <\/p>\n<pre><code class=\"ruby\"># add to app\/models\/user.rb  def class_name= value   self[:class] = value end  def class_name   self[:class] end <\/code><\/pre>\n<p>  \u041c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0430\u0446\u0435\u0441\u0441\u043e\u0440 &#8216;class_name&#8217;, \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0433\u0435 \u0443\u0433\u043e\u0434\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0444\u043e\u0440\u043c\u0430\u0445:  <\/p>\n<pre><code class=\"ruby\">&lt;%= f.text_field :class_name %&gt; <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u0432 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u0430\u0445:  <\/p>\n<pre><code class=\"ruby\">validates_presence_of :class_name <\/code><\/pre>\n<p>  \u0418\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442:  <\/p>\n<pre><code class=\"ruby\">User.create :class_name =&gt; 'class of 1995' <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043a\u0430\u0447\u0430\u043b\u0438 \u043a\u043e\u0434, \u0442\u043e \u044d\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f test-driven, \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0443 \u0442\u043e, \u0447\u0442\u043e \u044f \u043f\u0438\u0441\u0430\u043b \u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0441\u0430\u043c\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043f\u043e\u0434\u043e\u0431\u0430\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041f\u0440\u0438\u0437\u044b\u0432\u0430\u044e \u0432\u0430\u0441 \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435.<\/p>\n<p>  \u0423\u0434\u0430\u0447\u0438!<\/p>\n<p>  <a href=\"http:\/\/kconrails.com\/2011\/01\/28\/legacy-database-table-column-names-in-ruby-on-rails-3\/\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d<\/a>    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/155215\/\"> http:\/\/habrahabr.ru\/post\/155215\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041e\u0441\u043d\u043e\u0432\u0430\u043d\u043e \u043d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u0445, \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u0435\u0434\u0448\u0438\u0445(\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0445) \u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043b\u044e\u0434\u044c\u043c\u0438.<br \/>  <a href=\"https:\/\/github.com\/kconrails\/safe_attributes_example\"><img decoding=\"async\" src=\"http:\/\/kconrails.files.wordpress.com\/2010\/11\/download3.png?w=450\"\/><\/a><br \/>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u0430\u0437\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0443 \u0432\u0430\u0441 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043f\u043e\u043b\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u0442\u044c \u0441 Ruby on Rails. \u0421\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u044d\u0442\u043e \u043f\u043e\u043b\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c &#8216;class&#8217; \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446. \u0420\u0435\u043b\u044c\u0441\u0430\u043c \u044d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f. \u042d\u0442\u043e \u043a\u0430\u043a \u0442\u0435\u0449\u0430, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435 \u043d\u0440\u0430\u0432\u0438\u0442\u0441\u044f \u0442\u0432\u043e\u044f \u043d\u043e\u0432\u0430\u044f \u043f\u0440\u0438\u0447\u0435\u0441\u043a\u0430, \u0438 \u043e\u043d\u0430 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043f\u0440\u0438 \u043b\u044e\u0431\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438.   <\/p>\n<blockquote><p>\u0412 \u0432\u0438\u0434\u0443 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u0434\u0440\u0430\u043c\u0430\u0442\u0443\u0440\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0442\u0430\u043b\u0430\u043d\u0442\u0430, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0447\u0438\u043a \u043d\u0435 \u0441\u043c\u043e\u0433, \u043f\u043e\u0440\u043e\u0434\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u044f\u0440\u043a\u0443\u044e \u043c\u0435\u0442\u0430\u0444\u043e\u0440\u0443, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0443\u044e \u043e\u0431\u0449\u0443\u044e \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0446\u0438\u044e, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u043f\u043e\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u043d\u043e\u0439  <\/p><\/blockquote>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-155215","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/155215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=155215"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/155215\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=155215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=155215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=155215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}