i want to get value from 2 diffrent field, first
from text_field, and second from select_date, and i want to save it in
one field “TTL” in database, this is the syntax,
i change my model file to be like this:
i want to get value from 2 diffrent field, first
from text_field, and second from select_date, and i want to save it in
one field “TTL” in database, this is the syntax,
i change my model file to be like this:
See: ActiveRecord::Base (search
“serialize”) …If you want to be able to be able to select by that
field you’ll need a custom serializer and PostgreSQL so you can use
Hstore (you can also use JSON datatype in PostgreSQL 9.2 but that
requires even more work because JSON is still a new feature so it
doesn’t have the same select support that Hstore has.)
Have a good look at the Rails Guide on Debugging. It will show you
how to debug your code.
Also I suggest that you work right through a good tutorial on Rails,
such as railstutorial.org, which is free to use online. Then you will
get a better understanding of how Rails works.
but it make this error
{:as=>:TTL} is not a symbol
can you help me?
I told you to read on virtual attributes and callbacks. To give you a
clue on what you need to do, you need to create 2 virtual atteibutes:
one for the text field and one for the date select. Then use a before
validation callback to concatenate them. Or just as colin suggested,
concatenate them in the controller but i’d like to so these things in
the model.
but it make this error
{:as=>:TTL} is not a symbol
can you help me?
I told you to read on virtual attributes and callbacks. To give you a clue on
what you need to do, you need to create 2 virtual atteibutes: one for the text
field and one for the date select. Then use a before validation callback to
concatenate them. Or just as colin suggested, concatenate them in the controller
but i’d like to so these things in the model.
You are right of course Jim, I was just trying to make it easier for
the guy to understand, but yes, Mas B. it is better to put such code
in the model.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.