小编Edw*_*año的帖子

heroku - 如何查看所有日志

我在heroku上有一个小应用程序.每当我想看日志时,我都会去命令行做

heroku logs
Run Code Online (Sandbox Code Playgroud)

这只能让我看到大约100行.有没有办法在heroku上查看我们的应用程序的完整日志?

logging heroku

452
推荐指数
11
解决办法
26万
查看次数

我们如何看Rails开发日志?

我的团队成员正在Windows XP上开发Rails应用程序.我们发现,当我们运行应用程序时,无论是在NetBeans中启动它还是打开控制台并调用script/server,Rails开发日志都不会滚动.只有Webrick启动消息.该应用程序肯定在运行,但是当我们在浏览器中点击各个页面时,我们没有看到任何日志记录输出.

当我在OS X系统上查看相同的应用程序时,日志记录输出按预期工作.

我确实确保它在Rails"开发"环境中运行.

有什么想法可以抑制日志记录?

是否存在会影响它的environment.rb文件的配置参数?

ruby windows logging ruby-on-rails git-bash

54
推荐指数
3
解决办法
7万
查看次数

rspec,未知属性问题

我正在通过(优秀)railstutorial.org网站上有一个关于rspec的基本问题.

当我在新用户模型上运行以下测试时,我收到"未知属性:用户名"消息和失败的测试.

  before(:each) do
   @attr = { :lname_e => "User", :fname_e => "Test", :email => "user@example.com", :username => "testUser" }
  end

  it "should create a new instance given valid attributes" do
    User.create!(@attr)
  end
Run Code Online (Sandbox Code Playgroud)

错误语法是

Failures:
  1) User should create a new instance given valid attributes
     Failure/Error: User.create!(@attr)
     unknown attribute: username
     # ./spec/models/user_spec.rb:11:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

该字段位于users表(字符串)中,它在模型中为attr_accessible,在控制台中,我可以在测试中创建具有完全相同语法的用户.创建初始表后,通过迁移添加了此"用户名"字段,是否还需要在此处更新其他文件?

谢谢,

testing rspec ruby-on-rails

14
推荐指数
2
解决办法
3040
查看次数

语法错误,意外'\n',期待tCOLON2或'['或'.'

我在一个简单的测试应用程序上遇到以下错误,我正在努力学习Rails.

syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
Run Code Online (Sandbox Code Playgroud)

它似乎告诉我有一个意外中断,但我无法弄清楚我的代码有什么问题:

#app/views/quotations/index.html.erb
<% title "Quotations" %>

<table>
  <tr>
    <th>Quote Text</th>
    <th>Author</th>
    <th>Quote type</th>
    <th>Category</th>
    <th>Tags</th>
  </tr>
  <% for @quotations.each do |quotation| %>
    <tr>
      <td><%= quotation.quote_text %></td>
      <td><%= quotation.author %></td>
      <td><%= quotation.quote_type %></td>
      <td><%= quotation.category %></td>
      <td><%= quotation.tags %></td>
      <td><%= link_to "Show", [@user, quotation] %></td>
      <td><%= link_to "Edit", edit_user_quotation_path(@user, quotation) %></td>
      <td><%= link_to "Destroy", [@user, quotation], :confirm => 'Are you sure?', :method => :delete %></td>
    </tr>
  <% end %>
</table> …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails syntax-error

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

传递参数以更新嵌套属性

我正在开发一个非常基本的练习应用程序,用户可以在其中创建多个引用.我遇到的问题是我无法更新我的报价.我有很多东西,并在谷歌和其他问题阅读,但无法弄清楚我做错了什么.这是我的代码:

#User Model
    class User < ActiveRecord::Base
      has_many :quotations, :dependent => :destroy
      attr_accessible :quotations
      accepts_nested_attributes_for :quotations, :allow_destroy => true
    end

#Quotations Model
class Quotation < ActiveRecord::Base
  attr_accessible :quote_text, :author, :quote_type, :category, :tags, :user_id
  belongs_to :user
end
Run Code Online (Sandbox Code Playgroud)

报价控制器

class QuotationsController < ApplicationController
  before_filter :get_user

  def get_user
    @user = User.find(params[:user_id])
  end 

  def edit
    @quotation = @user.quotations.find(params[:id])
  end

  def update
    @quotation = @user.quotations.find(params[:id]) 
    if @quotation.update_attributes(params[:id])
      redirect_to user_quotation_path :notice  => "Successfully updated quotation."
    else
      render :action => 'edit'
    end
  end    

end
Run Code Online (Sandbox Code Playgroud)

parameters ruby-on-rails parameter-passing nested-attributes

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

C:/Sites/rails_projects/sample_app/app/controllers/users_controller.rb:23:语法错误,意外$ end,期待kEND

我是编程和自学RoR的新手.我使用http://ruby.railstutorial.org作为我的第一个指南.我以为自己表现不错,然后出现了一个看似简单的问题,即使在与该主题相关的堆栈上发布了几篇关于好帖子后,我仍然无法修复它.如果有人能够在我的代码中指出我遇到的问题,我将不胜感激.

谢谢.

我收到了这个错误.

C:/Sites/rails_projects/sample_app/app/controllers/users_controller.rb:23:语法错误,意外$ end,期待kEND

这是我正在使用的代码:

class UsersController < ApplicationController

def show
  @user = User.find(params[:id])
  @title = @user.name
end

def new
  @user = User.new
  @title = "Sign up"
end

def create
  @user = User.new(params[:user])
  if @user.save
  sign_in @user
  flash[:success] = "Welcome to the Sample App!"
  redirect_to @user
else
  @title = "Sign up"
  render 'new'
 end
end
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails syntax-error ruby-on-rails-3

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