Closed david135 closed 7 years ago
I can confirm that this pull request fixes Issue #22
NoMethodError: undefined method `type_cast_from_database' for "":String
@chip-miller I have added to my model but still not working? How did you get it to work?
@AhmedNadar - I pointed my Gemfile to this fork (and didn't really need to make any other changes).
gem "activerecord-tableless", ">= 1.3.4", git:'https://github.com/david135/activerecord-tableless.git'
I am not sure how you are using activerecord-tableless... In my situation I am using it to create a DummyClass
to test an ActiveSupport::Concern. Using (Rails 4.2, Postgres)
class UuidableDummy < ActiveRecord::Base
has_no_table
column :foo
include Uuidable
has_public_id :foo, prefix:'BAR'
end
describe Uuidable do
subject { UuidableDummy.new }
#etc.
end
I hope this is helpful.
@chip-miller Today I learned something new about target specific fork, thanks to you. This solved my issue, it is really helpful. Here is my code:
class Ewoks < ActiveRecord::Base
has_no_table
column :name, :string
column :email, :string
column :role, :string
validates_presence_of :name, :email, :role
validates_format_of :email, :with => /\A[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}\z/i
validates_length_of :role, :maximum => 100
end
Hope this fix would get merged.
Are there any news on this fix? We'd be quite eager for a new release. Thanks a lot for your consideration.
+1
+1
+1 However, it does not work in combination with the pg gem when having column type :string. Using type :varchar can be used as workaround, but is not ideal.
+1
Thank's chip-miller I do:
gem "activerecord-tableless", ">= 1.3.4", git:'https://github.com/david135/activerecord-tableless.git'
and works.
:+1:
Thank's chip-miller I do: gem "activerecord-tableless", ">= 1.3.4", git:'https://github.com/david135/activerecord-tableless.git' and works for us too.
+1
+1
I can confirm that this pr does indeed fix the issue with rails 4.2.x (I am using rails 4.2.5 as part of the learn-rails.com by Daniel Kehoe)
I am having the same issue as @kreintjes I am using rails 4.2.5.1 ruby 2.3.0.
class CampaignsWrapper < ActiveRecord::Base
has_no_table
column :remote_service_id, :string
end
Then in the command line:
wrapper = CampaignsWrapper.new(remote_service_id: "123456789")
ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR: type "string" does not exist
LINE 1: SELECT 'string'::regtype::oid
^
: SELECT 'string'::regtype::oid
from /usr/local/var/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:155:in `async_exec'
This stopped working in the Rails 4.2 beta. This seems to get it working, but it isn't comprehensively checked.