GithubHelp home page GithubHelp logo

Virtual attributes about validates_timeliness HOT 5 CLOSED

adzap avatar adzap commented on July 17, 2024
Virtual attributes

from validates_timeliness.

Comments (5)

corylanou avatar corylanou commented on July 17, 2024

Does anyone have a work around for this yet? If not, I'll fork and try to fix it. We are having the same issue.

from validates_timeliness.

corylanou avatar corylanou commented on July 17, 2024

Ok, this is a good work around btw:

class Post < ActiveRecord::Base
  attr_accessor :some_date
  columns_hash["some_date"] = ActiveRecord::ConnectionAdapters::Column.new("some_date", nil, "datetime")
  validates_date :some_date
end

from validates_timeliness.

corylanou avatar corylanou commented on July 17, 2024

I'm somewhat new to rails, but I'm thinking the fix for this bug would be to make this change in the file
/lib/validates_timeliness/orm/active_record.rb

def timeliness_attribute_timezone_aware?(attr_name)
  attr_name = attr_name.to_s
  columns_hash[attr_name] = ActiveRecord::ConnectionAdapters::Column.new(attr_name, nil, "datetime") unless columns_hash[attr_name]
  create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
end

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

Using the validators to get the type, and being more correct using the column class as @corylanou did

def timeliness_attribute_timezone_aware?(attr_name)
  attr_name = attr_name.to_s
  column = columns_hash[attr_name] || 
     ActiveRecord::ConnectionAdapters::Column.new(attr_name, nil, _validators[attr_name.to_sym].find {|v| v.kind == :timeliness }.type)
  create_time_zone_conversion_attribute?(attr_name, column)
end

Again untested should work in all 3.x versions of the plugin

from validates_timeliness.

adzap avatar adzap commented on July 17, 2024

I've pushed commit for this. Please test it out and see if it works, then I'll release a new version.

from validates_timeliness.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.