Ruby on Rails
Friday, January 19, 2018
On Friday, January 19, 2018 at 12:09:38 PM UTC-5, Walter Lee Davis wrote:
> On Jan 19, 2018, at 11:35 AM, fugee ohu <fuge...@gmail.com> wrote:
>
> I'm using form_for @object but i need to include in the form a value that's not a valid method for the object, but the controller needs the value How do I do that?
Where will this value come from (in the form)? Are you setting it using JavaScript or some other means? If you add attr_accessor :my_made_up_method_name to the model class, you can use the form builder macros to create a field for that attribute. You won't be able to set it to a value using Ruby (unless you use a callback to set it to some default value), but you can get the field to appear in the form that way.
Walter
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com .
> To post to this group, send email to rubyonra...@googlegrankoups.com .
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ .219238f6-f3ec-4170-95d5- 3246d167db5b%40googlegroups. com
> For more options, visit https://groups.google.com/d/optout .
Thanks
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fc994013-7b6c-4622-bae1-c347296944e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment