Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added support to models without database table #19

Merged
merged 2 commits into from

4 participants

@kennyadsl

Hi,
we needed humanizer for a model without database table and we made this change to support it.
This could be useful, for example, in contact forms that only send mail.

Instruction
To use this option just add in the model:

include Humanizer
require_human_on

without specifying no method.

Hoping to please.

NebuLab Team

@kennyadsl

Hi, after a long time I'd like to know if there is something wrong with this pull request.

Please let me know

Thanks

@akonan
Owner

Not sure if we need this? At least I was able to get it working without this.

In model I had:
include Humanizer
attr_accessor :tip, :humanizer_answer, :humanizer_question_id, :id

And in the controller I was able to ask valid? from the model

Did I misunderstand something here? And sorry for the looooong wait.

@kennyadsl

Hi,

We think it was a rails problem (we don't remember a lot about it :) ). Now it's solved and we forgot to close this pull request.

You can always manually fix or accept the other commit (5f01375) that solves an italian translation typo.

p.s. we are currently using your gem in our website http://nebulab.it and It works like a charm!

Thank you

@kennyadsl kennyadsl closed this
@coneybeare

This is not a rails problem. I can concur that when using a ORMless model, such as when implementing a simple contact form, the model.valid? call is not triggered when simply using:

include Humanizer
attr_accessor :humanizer_answer, :humanizer_question_id...

and calling model.is_valid? from the controller. This should be reopened.

@akonan akonan reopened this
@coneybeare

Thanks for reopening, I am using @kennyadsl's fork and can verify it works as intended.

@matiaskorhonen matiaskorhonen merged commit 5f01375 into kiskolabs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 22, 2011
  1. @kennyadsl
Commits on Aug 18, 2011
  1. @kennyadsl

    fixed typo

    kennyadsl authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +1 −1  lib/generators/templates/locales/it.yml
  2. +2 −2 lib/humanizer.rb
View
2  lib/generators/templates/locales/it.yml
@@ -35,7 +35,7 @@ it:
answers: ["21", "ventuno"]
- question: Che mese viene prima di luglio?
answer: "giugno"
- - question: Quanto fa quindici dviso tre?
+ - question: Quanto fa quindici diviso tre?
answers: ["cinque", "5"]
- question: Quanto fa 14 meno 4?
answers: ["10", "dieci"]
View
4 lib/humanizer.rb
@@ -50,8 +50,8 @@ def humanizer_check_answer
module ClassMethods
- def require_human_on(validate_on, opts = {})
- opts[:on] = validate_on
+ def require_human_on(validate_on = nil, opts = {})
+ opts[:on] = validate_on if validate_on
validate :humanizer_check_answer, opts
end
Something went wrong with that request. Please try again.