form fields not in schema

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

form fields not in schema

fugee ohu
I'm putting some fields in my form that the controllers gonna use but they're not columns in the table so I can't validate at the model level? How can I validate them?

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b9267aef-206d-49de-8b2a-becebafccd80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

form fields not in schema

batuhanwilhelm
You can still add unpersistent attributes to your model and validate them like any other attribute on schema.

You should treat these params like any other param at controller and permit them.

Add this to your model

attr_accessor :some_attribute

So then you can do MyModel.new(some_attribute: 'foo')




--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0532be8f-74e3-4597-8327-9d56eeb32d85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.