我已经安装了最后一个版本的will_paginate,我试图在我的视图中使用它,如下所示:
@courses = Course.paginate(:page => params[:page])
will_paginate @courses
Run Code Online (Sandbox Code Playgroud)
但是,我在视图中什么都没得到!任何的想法 ??
满足以下条件:
>> defined? WillPaginate
>> ActiveRecord::Base.respond_to? :paginate
Run Code Online (Sandbox Code Playgroud)
有什么我想念的吗?
我正在尝试写两个拒绝和批准行动的链接,但是,我不知道如何写出正确的路线,
我的路线.rb
put 'approve_class_room/:id(.:format)', :to => 'class_room_member_ships#approve'
put 'reject_class_room/:id(.:format)', :to => 'class_room_member_ships#reject'
Run Code Online (Sandbox Code Playgroud)
但是,在rake路线中,我得到:
PUT /approve_class_room/:id(.:format) class_room_member_ships#approve
PUT /reject_class_room/:id(.:format) class_room_member_ships#reject
Run Code Online (Sandbox Code Playgroud)
那么,什么是正确的link_to路径?
我的链接是
= link_to 'approve', approve_class_room_path
Run Code Online (Sandbox Code Playgroud)
它不会工作,我得到:
undefined local variable or method `approve_class_room_path'
Run Code Online (Sandbox Code Playgroud)
ps:我正在尝试让link_to使用AJAX工作,在同一页面上进行批准,AM我是否正确?什么是link_to路径?
有什么好主意吗?
我的应用程序在浏览器中,连接到socket.io服务器,它工作正常,但是,当客户端断开一段时间(例如睡眠)时,连接将由服务器自动关闭,这是socket.io的默认行为
如何在不刷新页面的情况下在客户端重新建立连接?是否有状态告诉我目前客户端的连接已关闭?这样我必要时重新连接?
我不能依赖一个事件,我想我需要知道本地连接是否打开或关闭..好吧?
我正在尝试安装capybara-webkit(0.8.0),但我得到下面的错误,可以任何身体帮助,我在ubuntu 11.10.
使用本机扩展安装capybara-webkit(0.8.0)Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展.
Run Code Online (Sandbox Code Playgroud)/home/sam/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb /usr/bin/qmake /usr/bin/make cd src/ && /usr/bin/qmake/home/sam/Documents/RoR/course_builder/CDPATH=/ruby/1.9.1/gems/capybara-webkit-0.8.0/src/webkit_server.pro -spec/usr/share/qt4/mkspecs/linux-g ++ - o Makefile.webkit_server/usr/bin/make cd src/&& make -f Makefile.webkit_server make [1]:输入目录
/home/sam/Documents/RoR/course_builder/CDPATH=/ruby/1.9.1/gems/capybara-webkit-0.8.0/src' g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtWebKit -I/usr/include/qt4 -I. -o RequestedUrl.o RequestedUrl.cpp make[1]: g++: Command not found make[1]: *** [RequestedUrl.o] Error 127 make[1]: Leaving directory/home/sam/Documents/RoR/course_builder/CDPATH=/ruby/1.9.1/gems/capybara -webkit-0.8.0/src'make :* [sub-src-webkit_server-pro-make_default-ordered]错误2make cd src/&& make -f Makefile.webkit_server make [1]:输入目录 …
ruby-on-rails-plugins capybara ruby-on-rails-3 capybara-webkit
在我按照heroku上的说明从DNSimple添加证书后,我在尝试访问网站时仍然出现此错误:
www.web.com使用无效的安全证书.
证书不受信任,因为未提供任何颁发者链.该证书仅对以下名称有效:*.herokuapp.com,herokuapp.com
(错误代码:sec_error_unknown_issuer)
那么,可能是什么问题呢?
虽然我将查询传递给存储库灵感来自这样的答案:
teams_users = Repo.all (from(t in Team, where: t.owner_id == ^user_id))
|> Enum.each( &team_users/1 )
def team_users (team) do
%{id: id} = team
Repo.all (from(tu in TeamUser, where: tu.team_id == ^id))
end
Run Code Online (Sandbox Code Playgroud)
但是,我收到了这个错误:
[error] GenServer #PID<0.450.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for #Ecto.Query<from t in App.Team, where: t.owner_id == ^1>
(elixir) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) lib/enum.ex:116: Enumerable.reduce/3
(elixir) lib/enum.ex:1477: Enum.reduce/3
(elixir) lib/enum.ex:609: Enum.each/2
(App) web/channels/user_channel.ex:93: App.UserChannel.handle_in/3
(phoenix) lib/phoenix/channel/server.ex:223: Phoenix.Channel.Server.handle_info/2
(stdlib) gen_server.erl:615: :gen_server.try_dispatch/4
(stdlib) gen_server.erl:681: :gen_server.handle_msg/5
(stdlib) proc_lib.erl:240: …Run Code Online (Sandbox Code Playgroud) 我试图绑定凤凰,"0.0.0.0"我尝试config.exs过:
config :app, App.Endpoint,
url: [host: "0.0.0.0"],
Run Code Online (Sandbox Code Playgroud)
而且,我尝试dev.exs过:
config :app, App.Endpoint,
http: [host: "0.0.0.0", port: 4000],
Run Code Online (Sandbox Code Playgroud)
但都没有奏效:
[info] Running App.Endpoint with Cowboy using http://localhost:4000
[warn] Transport option {:host, "0.0.0.0"} unknown or invalid.
Run Code Online (Sandbox Code Playgroud)
那么,正确的方法是什么?
我正在尝试返回这样的响应:
return response()->json(['name' => 'Abigail', 'state' => 'CA']);
Run Code Online (Sandbox Code Playgroud)
但是,我遇到了错误:
Target [Illuminate\Contracts\Routing\ResponseFactory] is not instantiable.
Run Code Online (Sandbox Code Playgroud)
任何的想法?
这是我的 composer.json:
{
"name": "laravel/lumen",
"description": "The Laravel Lumen Framework.",
"keywords": [
"framework",
"laravel",
"lumen"
],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.5.9",
"laravel/lumen-framework": "5.2.*",
"vlucas/phpdotenv": "~2.2",
"generationtux/jwt-artisan": "^0.1.7",
"barryvdh/laravel-cors": "^0.8.0",
"neomerx/cors-illuminate": "^1.1",
"fenos/notifynder": "3.1.*",
"franzose/closure-table": "^4.1",
"mlntn/lumen-artisan-serve": "~1",
"guzzlehttp/guzzle": "~6.0",
"league/flysystem": " ~1.0",
"bugsnag/bugsnag-laravel": "^2.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"phpunit/phpunit": "~4.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"GuzzleHttp\\": "/vendor/guzzlehttp/"
},
"classmap": …Run Code Online (Sandbox Code Playgroud) 我在这样的DC(DrawingContext)上绘制Grid:
dc.DrawImage(_imageSource, new Rect(x, y, width, height);
Run Code Online (Sandbox Code Playgroud)
但是,如果要旋转在绘图上下文中绘制的图像怎么办?
我知道我可以将效果推送到工程图上下文,但是,这将影响所有工程图,而我只想旋转的工程图_imageSource。
任何的想法?