Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm inclined to disagree with the approach to use attr_accessors for action-specific entry elements. If Ts&amp;Cs need to be recorded then that makes sense, but sometimes you need data that really is unrelated to the model and is only related to the specific action at hand, such as 'perform some heavyweight operation when executing the action'. </p> <p>Lets say you have a sign-up form, and you're not using OAuth, and you have an option to specify twitter username and password on sign up. This is fine:</p> <pre><code>&lt;%= form.input :twitter_username %&gt; &lt;%= form.input :twitter_password, :as =&gt; :password %&gt; </code></pre> <p>But this bit below confuses me -- its like formtastic in this case is actually taking away what is already there. Is there a way of adding params[:your-object] while still getting formastic to do all its lovely layout stuff? </p> <p>How about:</p> <pre><code>class User &lt; ActiveRecord::Base ... #I don't want this here. Its only for UserController#create. #attr_accessor :tweet_when_signed_up ... end </code></pre> <p>and:</p> <pre><code>&lt;%= form.input :tweet_when_signed_up, :as =&gt; :checkbox, :param_only =&gt; true %&gt; </code></pre> <p><code>param_only</code> is my made-up suggestion. It says 'this isn't even a transient property. Its just for this action. </p> <pre><code>class UserController &lt; ActionController::Base ... def create if params[:tweet_when_signed_up] # haven't done this yet -- == 1 or !.nil? Tweeter.tweet( ... ) end @user = User.create( params[:user] ) end </code></pre> <p>The ability to do this is probably there -- does anyone know how to do effectively what I think is a good idea above? </p> <p>thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload