You are here: Forums Ask a Rails expert magic timestamps...
Posted in Forums : Ask a Rails expert
Authority 12
Posting Rating 0
Sign in to rate this post
|
It surely must be my host, but the created_at field gets populated in the database but when i try to access it, using @company.created_at it is nil
|
|
Authority 0
Posting Rating 74
Sign in to rate this post
|
Never had that happen. I see you have a created_by attribute in there. Where and how is that being set. My guess is that you have something overriding the default rails timestamps and it is not working as expected. Does updated_at work as expected? |
Authority 12
Posting Rating 0
Sign in to rate this post
|
I set the created_by using the current_user from restfulauthentication. The thing I don’t get is that its getting populated from the active record, but when you access it then its nil. |
Authority 12
Posting Rating 0
Sign in to rate this post
|
Sorry updated_at does not work either |
Authority 12
Posting Rating 93
Sign in to rate this post
|
Odd… what does @company.attributes[‘created_at’] report? And what happens if you use company=Company.find(:first) (without the ”@” prefix), and then try company.created_at? |
Authority 12
Posting Rating 96
Sign in to rate this post
|
Certainly a weird problem. What database are you using? Can you go to the db console and execute “describe companies” so we can check the field types? Have you hooked into any of the ActiveRecord callbacks in your Company model? Do you get anything for company.updated_at_before_type_cast or company.created_at_before_type_cast ? |
Authority 37
Posting Rating 100
Sign in to rate this post
|
Colin: Does this happen with other records as well or is this the only record with problems? And, as Jon said, having those attributes’ values before typecast may help find the problem. |
Authority 12
Posting Rating 0
Sign in to rate this post
|
It sounds like your Company model is doing something bad. Could you post a copy of it. Also what version of Rails are you on. |
Authority 12
Posting Rating 0
Sign in to rate this post
|
Hi, Thanks for all your time and input sorry for the delay getting back long weekend here I’m using SQLSERVER 2005. @company.attributes[‘created_at’] reports @company.created_at_before_type_cast reports and @company.created_at comes back with nil code is class Company < ActiveRecord::Base has_many :users has_many :employees validates_presence_of :company_registered_number, :message => “The Company Registered Number cannot be blank” validates_presence_of :address_line_1, :city, :state, :country, :parent, :ultimate_parent :message => “cannot be blank”
|
Authority 12
Posting Rating 96
Sign in to rate this post
|
validates_presence_of :address_line_1, :city, :state, :country, :parent, :ultimate_parent :message => “cannot be blank”
There’s a comma missing on that line, before :message. Can you paste your code again, but put html code tags around it? |
Authority 12
Posting Rating 0
Sign in to rate this post
|
Hi, after much angst, i’ve tracked this down to an issue with a plugin – its the validate_dates plugin. I’m contacting the author for some advice. |
Ask a Rails expert : Sanitizing html
Ask a Rails expert : First post, requesting sage perspective
Ask a Rails expert : How to use mephisto
Ask a Rails expert : How to use mephisto
Ask a Rails expert : will_paginate customization problem
Ask a Rails expert : BackgroundRB still wants 'development' environment...?
Ask a Rails expert : activescaffold, sql exception
Ask a Rails expert : Passing non-english chars in query string
Ask a Rails expert : Rails and 2D barcodes
Ask a Rails expert : apache giving proxy error