问题标签 [ruby-on-rails]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1011 浏览

ruby-on-rails - 向 Rails 添加功能

我正在开发一个 Rails 应用程序,并希望从我询问的“在 Ruby on Rails 中获取主机名或 IP ”中包含一些功能。

我在让它工作时遇到问题。我的印象是我应该在 lib 目录中创建一个文件,所以我将它命名为“get_ip.rb”,内容如下:

我也尝试过将 GetIP 定义为一个类,但是当我执行通常的操作时ruby script/console,我根本无法使用该local_ip方法。有任何想法吗?

0 投票
3 回答
2417 浏览

ruby-on-rails - 如何在 Rails 中实现 OpenID 服务器?

我在 Ubuntu上看到了类似的问题,但我有兴趣通过我的基于 Rails 的站点托管我自己的 OpenID 提供程序,该站点已经有一个身份和身份验证系统。

请注意,我不是在寻找将站点用作 OpenID的委托方法。

正确执行此操作的最佳方法是什么?

0 投票
3 回答
937 浏览

ruby-on-rails - 将数据从 Ruby on Rails 应用程序传递到 Flex 图表的最佳方式是什么?

有很多方法可以将数据从 Rails 应用程序传递到 Flex 二进制文件。现在,我正在使用带有 xml.erb 模板的旧 e4x resultFormat。我以前做过 AMF,但我觉得将参数内联到嵌入本身是一个更好的解决方案,因为您不必等待浏览器加载 swf 二进制文件和二进制文件来发出 Web 请求。

考虑到所有这些,如今使用 Rails 后端渲染 Flex 小部件的最佳实践是什么?

0 投票
8 回答
9352 浏览

ruby-on-rails - 如何在 Ruby on Rails 中进行全文搜索?

我想在我的 Ruby on Rails 应用程序中对数据进行全文搜索。存在哪些选择?

0 投票
3 回答
1481 浏览

ruby-on-rails - How can I upsert a bunch of ActiveRecord objects and relationships in Rails?

I am working with an API that provides bus arrival data. For every request, I get back (among other things) a list of which routes serve the stop in question. For example, if the list includes result for bus route #1, 2, and 5, then I know that those serve this stop.

I have a many-to-many relationship set up between Route and Stop, and I want to dynamically check and update these associations on every request. There is no "master list" of which routes serve which stops, so this seems like the best way to get this data.

I believe that the way I'm doing it now is very inefficient:

Basically, I have to do 2 things for every route I find: 1) Create it if it doesn't already exist, 2) Add a relationship to the current stop if it doesn't already exist.

Is there a better way to do this, for example by getting a bunch of the data in memory and doing some of the processing on the app server side, in order to avoid the multitude of database calls I'm currently doing?

0 投票
9 回答
38476 浏览

ruby-on-rails - 最佳 Ruby on Rails 社交网络框架

我正计划使用 Ruby on Rails 创建一个社交网络 + MP3 讲座下载/浏览/评论/发现网站。部分是为了好玩,也是学习一些 Ruby on Rails 的一种方式。我正在寻找一个可以用作我的网站基础的社交网络框架。我不想重新发明轮子。

在网上搜索我发现了三个这样的框架。您会推荐使用这三个中的哪一个,为什么?

http://portal.insoshi.com/

http://www.communityengine.org/

http://lovdbyless.com/

0 投票
2 回答
2024 浏览

ruby-on-rails - 在 Rails 2.1.x 中处理 RoutingError 的最佳方法?

我正在使用 Rails 2.1 中的 routing.rb 代码,并试图让它达到我可以对找不到适当路径时抛出的 RoutingError 异常做一些有用的事情的地步。

这是一个有点棘手的问题,因为有些类型的 URL 只是简单的 BAD:/azenv.php 机器人攻击,在 URL 中键入 /bar/foo/baz 的人,等等......我们不想要那。

然后是微妙的路由问题,我们确实希望收到通知:例如 /artists/ 或 ///。在这些情况下,我们可能希望或不抛出错误......或者我们让 Google 向我们发送过去有效但不再是因为人们删除它们的 URL。

在每种情况下,我都想要一种方法来包含、分析和过滤我们返回的路径,或者至少是某种 Railsy 方法来管理通过正常的“fallback catchall”url 的路由。这存在吗?

编辑:

所以这里的代码是:

所以我们最好的选择是覆盖 log_error(exception) 以便我们可以根据异常过滤掉异常。所以在 ApplicationController

在我们需要不同的控制器逻辑、路由等的地方添加额外的逻辑。

0 投票
1 回答
8708 浏览

ruby-on-rails - 如何在 Rails 中删除通配符 cookie?

如何删除使用通配符域设置的 Rails 中的 cookie:

当遵循docs时,您可以:

日志说

请注意,缺少域(似乎对所有内容都使用默认参数)。尊重 RFC,当然 cookie 还在那里,浏览器 -> ctrl/ cmd- L->

瞧!

问:删除此类 cookie 的“正确”方法是什么?

0 投票
4 回答
520 浏览

ruby-on-rails - Ruby on Rails 中使用 Restful_Authentication 的纯文本密码

如果我在我的 ruby​​ on rails 应用程序中使用 restful_authentication,密码会在浏览器和服务器之间以 paintext 传输吗?如果是这样,我应该对此有多担心?

0 投票
9 回答
11172 浏览

ruby-on-rails - Ruby 的自动代码质量工具?

关于 Java,我真正怀念的一件事是工具支持。FindBugs、Checkstyle 和 PMD 实现了代码质量指标和自动错误检查的三位一体。

是否有任何东西可以检查简单的错误和/或 Ruby 代码的样式违规?如果我可以将它改编为 Rails 等框架,那么我可以加分,以便遵循 Rails 惯用语。