softace / activerecord-tableless

Bringing together the different tableless model implementations into a single gem/plugin
Other
113 stars 41 forks source link

fix for rails-4.2.0.betaX #23

Closed david135 closed 7 years ago

david135 commented 10 years ago

This stopped working in the Rails 4.2 beta. This seems to get it working, but it isn't comprehensively checked.

charlotte-miller commented 9 years ago

I can confirm that this pull request fixes Issue #22

NoMethodError: undefined method `type_cast_from_database' for "":String
AhmedNadar commented 9 years ago

@chip-miller I have added to my model but still not working? How did you get it to work?

charlotte-miller commented 9 years ago

@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.

AhmedNadar commented 9 years ago

@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.

sudoremo commented 9 years ago

Are there any news on this fix? We'd be quite eager for a new release. Thanks a lot for your consideration.

helloenvoy-andrew commented 9 years ago

+1

DerekH commented 9 years ago

+1

kreintjes commented 9 years ago

+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.

bekicot commented 9 years ago

+1

romenigld commented 9 years ago

Thank's chip-miller I do: gem "activerecord-tableless", ">= 1.3.4", git:'https://github.com/david135/activerecord-tableless.git' and works.

liaden commented 9 years ago

:+1:

ghost commented 9 years ago

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.

fguillen commented 8 years ago

+1

dalupus commented 8 years ago

+1

TheBrockEllis commented 8 years ago

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)

amitfriedman12 commented 7 years ago

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'