<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sean&#039;s Blog &#187; getters</title>
	<atom:link href="http://seanbehan.com/tag/getters/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Trouble Using Attr_Accessor in Rails Models and Forms</title>
		<link>http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/</link>
		<comments>http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 17:06:14 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[attr_accessor]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[getters]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[setters]]></category>
		<category><![CDATA[troubleshooting]]></category>
		<category><![CDATA[validations]]></category>
		<category><![CDATA[virtual attributes]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=489</guid>
		<description><![CDATA[You might use the attr_accessible method to create getters and setters for a class that has attributes which don&#8217;t map directly to corresponding fields in a database. For example let&#8217;s take the scenario where you are processing a credit card transaction. You don&#8217;t want to save the credit card details, such as card number and [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Ftrouble-using-attr_accessor-in-rails-models-and-forms%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Trouble Using Attr_Accessor in Rails Models and Forms" data-url="http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>You might use the attr_accessible method to create getters and setters for a class that has attributes which don&#8217;t map directly to corresponding fields in a database. For example let&#8217;s take the scenario where you are processing a credit card transaction. You don&#8217;t want to save the credit card details, such as card number and verification value etc, however you still want to use these attributes in a form and you want to perform validations on them.</p>
<pre class="wp-code-highlight prettyprint">
class CreditCardPurchase &lt; ActiveRecord::Base
  attr_accessor :number, :cvv
end
</pre>
<p>The only probem that I&#8217;ve run into is using the attr_accessor on datetime select form fields. Rails won&#8217;t be able to determine the &#8220;klass&#8221; and will spit out a nasty error. Looks there is some discussion around this bug. I&#8217;ve got another post about this topic http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/ but unfortunately not a whole lot of resultion :(</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/trouble-using-attr_accessor-in-rails-models-and-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

