小编KUL*_*ING的帖子

每5分钟后启动Android服务

我在网上搜索了最近2天,但我找不到任何有用的教程.我已经创建了一个服务,我在服务启动时在状态栏中发送通知.我希望该服务在显示通知后停止,并在5分钟后再次启动.如果有可能请告诉我,如果有的话,请给我一些有用的教程.我听说过,TimerTask并且AlarmManager我也尝试使用它们,但我无法获得理想的结果.

编辑:我需要每5分钟启动一次服务,即使我的应用程序没有运行.

service android alarmmanager timertask

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

类的最高级别不匹配CommentsController(TypeError),重命名的最佳方法是什么?

今晚我在部署时遇到了一些问题,我试图尽快解决这个问题

我不知道为什么会这样.一切都在本地很好,但不是在heroku上.我在研究之后尝试了各种不同的修复,但我可能不得不完全重命名这个类的CommentsController(希望这很有效).最好的方法是什么?我对Rails很陌生,所以我需要一些帮助才能正确地改变它们.

以下是CommentsController看起来像FYI的内容:

class CommentsController < ApplicationController
  def new
    @post = Post.new(params[:post])
  end

  def show
    @comment = Comment.find(params[:id])
    respond_to do |format|
      format.js
    end
  end

  def create
    @post = Post.find(params[:post_id])
    @comment = Comment.new(params[:comment])
    @comment.micropost = @post
    @comment.user = current_user
    if @comment.save
      redirect_to(:back)
    else
      render partial: 'shared/_comment_form', locals: { post: @post }
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

评论与每个帖子相关联(用户可以对帖子发表评论).如果需要,我也会发布其他代码.

这是heroku日志的错误

2013-04-09T05:55:19.454545+00:00 app[web.2]: /app/app/controllers/comments_contr
oller.rb:1:in `<top (required)>': superclass mismatch for class CommentsControll
er (TypeError)
Run Code Online (Sandbox Code Playgroud)

Routes.db

SampleApp::Application.routes.draw do
  resources :posts, :path => "posts"

  resources :users do
    resources …
Run Code Online (Sandbox Code Playgroud)

ruby model-view-controller ruby-on-rails ruby-on-rails-3

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

嵌入部分要点文件

在这里有一个要点.我使用以下代码将我的要点中的单个文件嵌入到网页中.

<script src="https://gist.github.com/4672365.js?file=1.java" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

但我想要的是从文件中嵌入一行1.java.您可以说我只想将文件中的第2行嵌入1.java到我的网页中.在此先感谢您的帮助:)

javascript git gist blogger github

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

How to check in JavaScript if table row with specific index exist?

I have this JavaScript block code:

var trows = table.getElementsByTagName('tbody')[0].rows;  
for(var j = ((pageNumber - 1) * rowsPerPage); j < ((pageNumber) * rowsPerPage); j++)
{
  trows[j].style.display = 'table-row';
}
Run Code Online (Sandbox Code Playgroud)

Before I implement this row:

 trows[j].style.display = 'table-row';
Run Code Online (Sandbox Code Playgroud)

I need to check if table row with scpecific index exists.

How to check in JavaScript if table row with specific index exist?

javascript

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