草庐IT

route_path

全部标签

ruby-on-rails - 使用 heroku rails 时出错,找不到数据库客户端 psql。检查您的 $PATH 并重试

尝试执行需要我执行railsdb的数据库操作我正在执行herokurunrailsdb但我得到了Runningrailsdbattachedtoterminal...启动,运行.7334找不到数据库客户端:psql。检查您的$PATH并重试。我做了:gemupdateheroku但是没有用。仍然出现相同的错误。还有:$herokurunbundleexecrailsdb--accountwork--appdmplanningRunning`bundleexecrailsdb`attachedtoterminal...up,run.1572Couldn'tfinddatabaseclie

ruby-on-rails - Rails 3.2.13 recognize_path 返回约束的路由错误

我的路由中有两条路径,同一条路径指向不同的Controller和Actionmatch'/:id'=>'users#show',:as=>'user',:constraints=>UserConstraintmatch'/:id'=>'customers#show',:as=>'customer'我的约束类有以下匹配项吗?方法defself.matches?(request)returnUser.exists?(request.path_parameters[:id])end当我在我的浏览器中调用url时,这工作正常。但是,这不适用于recognize_path方法。Rails.app

ruby-on-rails - 教程 Michael Hartl 在 9.3 上访问 edit_user_path 失败

我有一个我无法解决的错误。我按照教程中的步骤操作,但无法通过绿色测试。我遇到了这个错误:$bundleexecrspecspec/requests/user_pages_spec.rb-e"Editpage"Runoptions:include{:full_description=>/Edit\page/}FFFFailures:1)UserpagesEditpageFailure/Error:before{visitedit_user_path(user)}ActionView::Template::Error:undefinedmethod`model_name'forNilCla

ruby-on-rails - 在 routes.rb 上为 Ruby on Rails 的根设置可选参数

我正在使用static_pagesController来提供我所有的静态页面内容。我希望能够将参数传递给这个静态页面内容,以便打开几个用于登录和消息弹出窗口的模式框。root'static_pages#home'我该怎么做? 最佳答案 如果某些参数存在,您可以在View中使用Javascript执行此操作。例如在home.html.erb//firemodal然后只需将您的参数添加到查询字符串中:http://www.yoursite.com/?your_param=true无需修改路由文件。模态与View相关,那么为什么不将逻辑保

ruby-on-rails - articles_path 是如何工作的? (RubyOnRails 教程)

我正在关注theofficialrubyonrailstutorial我刚刚完成了第5.9章。添加链接应该很简单,但我很困惑。当我输入bin/rakeroutes时,我得到以下输出:fl4m3ph03n1x:~/blog$bin/rakeroutesPrefixVerbURIPatternController#ActionarticlesGET/articles(.:format)articles#indexPOST/articles(.:format)articles#createnew_articleGET/articles/new(.:format)articles#newedi

ruby-on-rails - 在 Rails Routes 中将 Controller 操作重定向到 root?

我的路由文件中有一个根路径:root'games#index'问题是如果有人去:http://domain.com/games它不显示根目录,因此我们为同一页面创建了两个URL。有没有办法将任何命中更改为http://domain.com/games至http://domain.com?如果在routes文件夹中有一个很好的方法,我宁愿不在应用程序Controller中摆弄before_filter。谢谢! 最佳答案 最简单的方法是设置重定向。map.redirect('/games','/')尽管如此,您的问题实际上是/games

ruby-on-rails - 将 routes.rb 文件分成多个文件以便更好地管理的好方法是什么?

我正在开发一个具有相当大的路由文件的Rails3项目。它利用了一些嵌套,我遇到了一个问题,主要是因为路由文件难以管理。有没有办法把它分成多个文件?类似于:My::Application.routes.drawdoconstraints(:subdomain=>'admin')doincludeMy::Application::Routes::AdminRoutesendincludeMy::Application::Routes::MainRoutesend或者...My::Application.routes.drawdoconstraints(:subdomain=>'admin'

ruby-on-rails - Rails 正在向后路由我的 calendar_event_path 吗?

Rails给我的URL的ID顺序错误。它将父ID传递给子代,将子ID传递给父代。在我的routes.rb中有resources:calendarsdoresources:eventsend哪个rakeroutes告诉我正在设置好的路线,例如calendar_eventGET/calendars/:calendar_id/events/:id(.:format){:controller=>"events",:action=>"show"}所以当我从我的部分View中请求该路线的路径时,它给了我一个id颠倒的url...http://localhost:3000/calendars//ev

ruby - LoadError : Expected {app_path}/models/model file. rb 定义模型名称

运行时出现错误LoadError:Expected/home/user/Desktop/Tripurari/myapp/app/models/host.rbtodefineHost##但它上面的每样东西都各就各位。有人能告诉我方法下面的确切问题是什么吗?defself.check_all(keyword)memo_mutex=Mutex.newmemo={}threads=[]name=keyword.keywordSITES.eachdo|site_and_options|threads 最佳答案 问题可能是由自动加载器引起的。如

ruby-on-rails - 为什么 `posts_path` 在 `rails console` 中不起作用?

为什么link_to'Back',posts_path在ERB中有效,但posts_path在控制台中无效?$railsconsoleirb(main):005:0>posts_pathNameError:undefinedlocalvariableormethod`posts_path'formain:Object 最佳答案 您需要在控制台中添加应用的上下文。app.posts_pathapp.getapp.posts_pathapp.responseapp.response.body