小编Las*_*ser的帖子

为什么我在"删除"请求中收到"无路由匹配[GET]"?Ruby on Rails

当我尝试删除communityfeed_item/micropost的内容时,我收到以下错误:

Routing Error

No route matches [GET] "/microposts/45"
Try running rake routes for more information on available routes.
Run Code Online (Sandbox Code Playgroud)

我检查我的路线并看到删除和发布,这是我真正需要的功能,但我一直收到"获取"错误.

posts GET    /posts(.:format)               posts#index
               POST   /posts(.:format)               posts#create
      new_post GET    /posts/new(.:format)           posts#new
     edit_post GET    /posts/:id/edit(.:format)      posts#edit
          post GET    /posts/:id(.:format)           posts#show
               PUT    /posts/:id(.:format)           posts#update
               DELETE /posts/:id(.:format)           posts#destroy
     locations GET    /locations(.:format)           locations#index
               POST   /locations(.:format)           locations#create
  new_location GET    /locations/new(.:format)       locations#new
 edit_location GET    /locations/:id/edit(.:format)  locations#edit
      location GET    /locations/:id(.:format)       locations#show
               PUT    /locations/:id(.:format)       locations#update
               DELETE /locations/:id(.:format)       locations#destroy
    communitys GET    /communitys(.:format)          communitys#index
               POST   /communitys(.:format)          communitys#create
 new_community GET    /communitys/new(.:format)      communitys#new …
Run Code Online (Sandbox Code Playgroud)

routes get ruby-on-rails http-delete

2
推荐指数
1
解决办法
2390
查看次数

在运行凤凰服务器时,如何让elixir编译器显示警告?

通过混合在iex会话中运行凤凰服务器,如:

iex -S mix phx.server
Run Code Online (Sandbox Code Playgroud)

有时候会列出一些警告:

Compiling 1 file (.ex)
warning: variable "user" is unused
  lib/app_web/controllers/user_controller.ex:37
Run Code Online (Sandbox Code Playgroud)

但似乎只是第一次运行服务器,之后我认为它是缓存的,所以它没有显示出来.我怎么能在以后看到这些警告来修复它们?谢谢.

elixir-mix elixir phoenix-framework iex

2
推荐指数
1
解决办法
515
查看次数

如何在 Phoenix (Elixir) 渲染中注入 HTML/使用变量操作 DOM,例如动态插入 SVG 或 PNG?

如果我有一些 svg 通过分配给变量上的视图svg,我可以使用以下命令渲染到视图中:

\n
<%= @svg %>\n
Run Code Online (Sandbox Code Playgroud)\n

然而,在 DOM 中,我可以检查页面并智能地看到 phoenix 默认不渲染 SVG,因为它是字符串表示形式。但是,我不知道如何覆盖该默认值,以便我可以正确地注入 dom/渲染 SVG,而不仅仅是在页面中显示字符串,而是实际渲染图像。我该怎么做?我是否必须使用 javascript 来渲染事实\xe2\x80\x94 这也没关系,但仅在服务器端渲染会非常好。

\n

非常感谢!

\n

javascript dom elixir phoenix-framework

2
推荐指数
1
解决办法
905
查看次数

Rails渲染HTML比静态HTML慢吗?

一个Rails布局

<%= image_tag("logo.png", :alt => "Sample App", :class => "round") %>
Run Code Online (Sandbox Code Playgroud)

将呈现为HTML

<img alt="Sample App" class="round" src="/images/logo.png" />
Run Code Online (Sandbox Code Playgroud)

如果网页必须呈现页面而不是直接获取HTML,网页加载速度会明显加快吗?我想弄清楚在Ruby中编写HTML的优势,除非是为了方便起见?

html ruby layout rendering ruby-on-rails

1
推荐指数
1
解决办法
241
查看次数

如何指定要使用的rails的postgres副本

如何指定postgres rails使用的版本?当我跑步puma去,localhost:3000我得到一个错误

PG::ConnectionBad
fe_sendauth: no password supplied
Run Code Online (Sandbox Code Playgroud)

我认为使用的副本可能是手动安装9.3,就像我运行时一样:

/usr/local/Cellar/postgresql/9.4.1/bin/pg_ctl -D /usr/local/var/postgres start
Run Code Online (Sandbox Code Playgroud)

我收到错误:

stgres start
server starting
LOG:  skipping missing configuration file "/usr/local/var/postgres/postgresql.auto.conf"
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.3, which is not compatible with this version 9.4.1.
Run Code Online (Sandbox Code Playgroud)

pg_hba.conf在我的系统上找到了三份副本:

/Library/PostgreSQL/9.3/data/pg_hba.conf
/Users/lasernite/Library/Application Support/Postgres/var-9.4/pg_hba.conf
/usr/local/var/postgres/pg_hba.conf
Run Code Online (Sandbox Code Playgroud)

我认为第一个是在某个时候手动安装.第二个可能只是一些支持副本/可忽略,第三个是自制安装.

如何让rails使用自制的postgres安装,即使这意味着擦除本地数据库?只要heroku上的产品不合适,哪个好.

我已经停留了几天,将我的开发环境从sqlite重新配置为postgres,这是非常有问题的,因为我现在有一个生产数据库和网站,这迫使我做一些代码推送而无法在本地验证功能,但是在很大程度上完全削弱了我进行任何开发的能力.

请帮我!

postgresql ruby-on-rails heroku puma ruby-on-rails-4

1
推荐指数
1
解决办法
1011
查看次数