小编Mic*_*Liu的帖子

在Rails 4中使用logger

我正在开发一个Rails 4项目,当我打电话给Rails.logger.debug "test"我尝试在线搜索时,我似乎无法在我的开发日志中显示任何内容,但我觉得我没有取得多大进展.我如何设置记录器并告诉它在我的开发日志文件中写入?

任何帮助将不胜感激.

logging ruby-on-rails-4

53
推荐指数
2
解决办法
8万
查看次数

在rails 4.0中发出问题,为删除操作创建link_to

这是我在rails中的第一个项目,即创建一个存储游戏数据的表.我能够从表格中显示关于赢家得分,输家得分等的数据.但是,我的表格列中存在包含每个游戏的删除链接的问题.

这是我在删除方法的游戏控制器中的代码:

def delete
  @game = Game.find(params[:game])
  @game.destroy()
  redirect_to :action => 'index'
end
Run Code Online (Sandbox Code Playgroud)

我的表代码片段,其中包含link_to命令的行

    <% @games_items.each do |t| %>
     <tr>
        <td><%= t.winner.name %></td>
        <td><%= t.loser.name %></td>
        <td><%= t.challenger.name %></td>
        <td><%= t.winner_score %></td>
        <td><%= t.loser_score %></td>
        <td><%= link_to 'Delete', delete_game_path(id: t.id)%></td>
     </tr>
    <% end %>
Run Code Online (Sandbox Code Playgroud)

在我调用的路由文件中

resources :games
Run Code Online (Sandbox Code Playgroud)

据我所知,这有助于生成基本路由.任何人都可以帮我弄清楚为什么我的link_to不起作用?

ruby resources routing ruby-on-rails ruby-on-rails-4

8
推荐指数
3
解决办法
2万
查看次数

在 windows powershell 上使用 django-admin

在启动新项目的Django教程中,要运行的命令是

django-admin.py startproject mysite
Run Code Online (Sandbox Code Playgroud)

但是,当我运行这个时,我总是遇到以下错误:

django-admin : The term 'django-admin' is not recognized as the name of a cmdlet, 
function, script file, or operable
program. Check the spelling of the name, or if a path was included, 
verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)

我已经将路径添加C:\Python33\Scripts到我的系统变量并重新启动了我的 powershell,但没有任何效果。我发现解决方法是执行以下操作:

py C:\Python33\Scripts\django-admin.py startproject mysite
Run Code Online (Sandbox Code Playgroud)

有什么办法可以解决这个问题,我只需要调用 django-admin.py 而不是指定目录?

说明:此错误与 Windows Powershell 相关。Windows 命令提示符工作正常,但我想知道是什么导致了这种差异

python django powershell

8
推荐指数
4
解决办法
2万
查看次数

从字符串获取星期几的Javascript方法?

假设我有一个如下字符串: 2013-11-22T08:50:33+0000 这是Friday, November 2013, 8:50:33.

我怎么会告诉它是星期五给出的字符串?

javascript string datetime parsing

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

将bootstrap按钮类添加到rails 4中的button_to

我在我的Rails 4 haml文件中有一个button_to调用,看起来像这样

= button_to("Click Me", action: "click", class: "btn btn-primary")
Run Code Online (Sandbox Code Playgroud)

但是,class: "btn btn-primary"代码段无法正常工作,我的按钮不会更改.我也尝试过旧的Ruby语法:class => "btn btn-primary",但这似乎没有办法.

任何帮助将不胜感激.

haml button twitter-bootstrap ruby-on-rails-4

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