About query database and virtual attributes

Hi,

My model has a lot of virtual attributes. So when I use
find(:all, :condition=>blablabla),
can I use virtual attribute directly?

eg. in my model:
def mydatetime
self.date+self.time
end
can i just use “mydatetime=xxx” to match the records in db?

of course, my model is far more complicated than this.

Any idea?

you would need to define mydatetime

def mydatetime=(datetime)
date = datetime.some_modifier
time = datetime.some_modifier
end

Keynan P. wrote:

you would need to define mydatetime

def mydatetime=(datetime)
date = datetime.some_modifier
time = datetime.some_modifier
end

Unfortunately, it doesn’t solve the problem.

Error messege:
Mysql::Error: Unknown column ‘who_chunk2’ in ‘where clause’: SELECT *
FROM skus WHERE (who_chunk2=‘Matt’)

My code is like:

def who_chunk2
if !self.who_chunk.blank?
if b=User.find_by_id(self.who_chunk)
b.name
end
end
end
def who_chunk2=(st)
if !st.blank?
self.who_chunk=User.find_by_name(st).id
end
end

Any update on this? I am also facing the same issue?

Please help!

On Jan 22, 7:32 am, Matt Z. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs