# Plain english to conditions in ror?

**URL:** <https://www.ruby-forum.com/t/plain-english-to-conditions-in-ror/196672>\
**Category:** Rails\
**Created:** [May 7, 2008, 6:59am UTC](https://www.ruby-forum.com/t/plain-english-to-conditions-in-ror/196672 "2008-05-07T06:59:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![varunkumargoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ed8c4c/32.png) [@varunkumargoel](https://www.ruby-forum.com/u/varunkumargoel)\
**Post date:** [May 7, 2008, 6:59am UTC](https://www.ruby-forum.com/t/plain-english-to-conditions-in-ror/196672/1 "2008-05-07T06:59:05Z")

</div>

Hi All,  
I wanna to do something like as:

1. Use will type plain English in text box like designation equals PM or  
designation = PM.

2.Then i have to save this rule in DB and i have to made some function  
to verify this rule.

1. My problem is that how to make if condition for following rule  
dynamically.Cos in ROR i can say designation == 'PM’then fine but how i  
will check that designation equals PM.

4.Means i have to make condition from plain english dynamically.

Please tell me ur suggestions.

Thanks  
Varun

---

<div class="post-metadata">

**Author:** ![varunkumargoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ed8c4c/32.png) [@varunkumargoel](https://www.ruby-forum.com/u/varunkumargoel)\
**Post date:** [May 7, 2008, 2:30pm UTC](https://www.ruby-forum.com/t/plain-english-to-conditions-in-ror/196672/2 "2008-05-07T14:30:58Z")

</div>

I would recommend that you create a DSL for your users. You can setup a  
mapping that abstracts away your domain specific names and allows for  
various types of rule creation. You need to guard/filter against code  
injection if you are eval-ing the rules directly.

Hope that helps.

On Wed, May 7, 2008 at 12:59 AM, Varun G. \<  
removed\_email\_address@domain.invalid\> wrote:

> dynamically.Cos in ROR i can say designation == 'PM’then fine but how i
> 
> >

–  
James M.

---

<div class="post-metadata">

**Author:** ![varunkumargoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ed8c4c/32.png) [@varunkumargoel](https://www.ruby-forum.com/u/varunkumargoel)\
**Post date:** [May 7, 2008, 7:06pm UTC](https://www.ruby-forum.com/t/plain-english-to-conditions-in-ror/196672/3 "2008-05-07T19:06:37Z")

</div>

Take a look at TreeTop. I’m not sure how complicated you want to get,  
but it might be what you are looking for.  
[http://www.rubyinside.com/treetop-powerful-but-easy-ruby-parser-library-701.html](http://www.rubyinside.com/treetop-powerful-but-easy-ruby-parser-library-701.html)

HTH

On May 6, 9:59 pm, Varun G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
