Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby on rails,将一个函数粘贴到textarea并执行它_Ruby On Rails - Fatal编程技术网

Ruby on rails Ruby on rails,将一个函数粘贴到textarea并执行它

Ruby on rails Ruby on rails,将一个函数粘贴到textarea并执行它,ruby-on-rails,Ruby On Rails,在我的应用程序中,我有一个文本区域,用户可以在其中粘贴一个函数,该函数在一个特定的散列上运行,该散列包含关于客户端的不同数据 <label >Function</label><textarea class="text" rows ="20" cols ="100" id="cell_option"><%=frst%></textarea> 这样做的目的是让用户尽可能多地操作和分析数据。 我唯一的问题是,在文本区域中,函数将保存为字符串

在我的应用程序中,我有一个文本区域,用户可以在其中粘贴一个函数,该函数在一个特定的散列上运行,该散列包含关于客户端的不同数据

<label >Function</label><textarea class="text" rows ="20" cols ="100" id="cell_option"><%=frst%></textarea>
这样做的目的是让用户尽可能多地操作和分析数据。 我唯一的问题是,在文本区域中,函数将保存为字符串,我没有找到如何执行字符串,以便ruby将其识别为一个函数,对数据进行操作。 明确给出了以下数据:

def execute_user_function(data)

**body from text area**

end

编辑:我确信我想这样做。我需要它,我知道后果。

执行用户提供的代码是一个非常糟糕的主意。我知道但我需要它。你确定要这样做吗?我确定要这样做。尝试使用eval方法
def execute_user_function(data)

**body from text area**

end