In Rails, is there a way to specify a TYPE you'd like an attr_accessor to be, and validate it using built-in Rails validation? -
I have not found a good way to do this, so I thought I would ask.
For example, in an ActiveRecord model, database backed attributes are automatically converted to the appropriate database-supported types. If I have a Rails know that Say I have many transient / synthetic properties that I want to validate, and they have specific types. I want to submit them with a form, and I want them to string or Define as an integer or a date (for example) to define how they are defined, but will automatically convert. If I had to declare something in the form of a rail model: What is the description of the rail There is an underlying method to "I" when you go to None of the answers answered a lot of questions. I believe the correct answer to the questions is "no" Both of the answers have been found by the fact that the possible answers to the question are "no", and these are both valid comments / views. category model, and there are some attributes in it, then say
name and
category_id , if I like it: <
name is a string and
category_id / Code is> is an integer.
attr_accessor: some_number_variable attr_accessor: some_date
Category.new (params [: Category]) "Parameters such as long time [Category:]: some_number_variable] and
params [: category] [: some_date] are part of the data submitted to the administrator (I know that the date can be given to many date formats there).
Comments
Post a Comment