是否有任何内置的调试功能可以在控制器中使用codeigniter?
在cakephp中有一个可以在控制器中使用的debug($ variable).
我可以使用var_dump($ variable); 或print_r($ variable);
但是,是否有任何内置的调试函数可供codeigniter在控制器中使用以获取任何变量的格式化结果?
Sprockets::FileNotFound in Home#index
Showing /home/user1/rorblog/app/views/layouts/application.html.erb where line #6 raised:
couldn't find file 'jquery'
(in /home/user1/rorblog/app/assets/javascripts/application.js:7)
Extracted source (around line #6):
3: <head>
4: <title>Rorblog</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
Run Code Online (Sandbox Code Playgroud)
但看起来所有文件都在那里.
application.html.erb =>
<!DOCTYPE html>
<html>
<head>
<title>Rorblog</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="container">
<div id="header">
<ul class="hmenu">
<li>
<%= link_to('Home', home_index_path ) %>
</li>
<% if user_signed_in? …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails ruby-on-rails-3.1 sprockets asset-pipeline
我需要从字符串中删除/剪切前300个单词或字符.
这意味着,从一开始我就需要字符串中有限数量的字符.
截断的东西.
有这个功能吗?
我读了这个: jQuery ajax表单提交了多次
它没有帮助。
如果我在表单上键入内容并单击提交按钮,则它将发送一个请求。第二次,如果我键入内容并单击,它会发送两个请求。第三次发送三个请求,依此类推。为什么是这样?我在jquery代码中做任何错误吗?
这是我的代码:
index.php =>
<div id="id_div_1" class="cl_div_comment_container"></div>
<form id="id_form_1" method="POST">
<input type="hidden" value="1" name="nm_hidden_post_id">
<textarea class="cl_textarea_comment" style="resize:none;" rows="1" cols="50" name="nm_comment_content"></textarea>
<input class="cl_submit_comment" type="submit" value="Comment" name="nm_submit_comment">
</form>
Run Code Online (Sandbox Code Playgroud)
javascript.js =>
$(document).ready(function(){
console.log('hello');
$('input[name="nm_submit_comment"]').on('click',function(){
var frm = $(this).closest("form")[0];
var frm_id = $(frm).attr("id");
var frm_id_splitted = frm_id.split("_");
var frm_id_splitted_2 = frm_id_splitted[2];
console.log($('div#id_div_' + frm_id_splitted_2));
$(frm).on('submit',function(e){
e.preventDefault();
frm_serialized = $(this).serialize();
console.log(frm_serialized);
$.ajax({
url: "save-comment.php",
method: "POST",
data: frm_serialized,
success: function(data) {
console.log(data);
$('div#id_div_' + frm_id_splitted_2).append(data);
}
});
});
});
});
Run Code Online (Sandbox Code Playgroud)
save-comment.php …
有帖子和评论表.
对于一篇帖子,有多条评论.
如果我删除一个帖子,那么该帖子的评论会在cakephp中自动删除吗?
div#id_div_allposts {
width: 100%;
}
div.class_div_post {
width: 100%;
}
div.class_div_editdelete {
width: 100%;
}
Run Code Online (Sandbox Code Playgroud)
我怎么能用一行写呢?
那么选择带有id和class的html标签的方法是什么?
<li><%= link_to('More Commented', posts_morecommented_path) %></li>
Run Code Online (Sandbox Code Playgroud)
错误
ActiveRecord::RecordNotFound in PostsController#show
Couldn't find Post with id=morecommented
Request
Parameters:
{"id"=>"morecommented"}
Run Code Online (Sandbox Code Playgroud)
我在哪里做错了?
postscontroller #show action
def show @post = Post.find(params[:id]) ... end
Run Code Online (Sandbox Code Playgroud)
morecommented.html.erb
<% @moreCommented.each do |t| %>
<%= link_to t.title, :controller => '/posts', :action => 'show', :id => t.id %><br/>
<% end %>
Run Code Online (Sandbox Code Playgroud)
耙路线
post GET /posts/:id(.:format) {:action=>"show", :controller=>"posts"}
....
posts_morecommented /posts/morecommented(.:format) {:controller=>"posts", :action=>"morecommented"}
Run Code Online (Sandbox Code Playgroud)
routes.rb中:
resources :posts
match "posts/:id/categ" => "posts#categ"
match "posts/:id/tag_posts" => "posts#tag_posts"
match "posts/searcharchive" => "posts#searcharchive"
match "posts/morecommented" => "posts#morecommented"
Run Code Online (Sandbox Code Playgroud) ruby routing ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1
from django.db import models
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.CharField(max_length=1000)
created = models.DateField()
modified = models.DateField()
Run Code Online (Sandbox Code Playgroud)
python manage.py syncdb出错:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, …Run Code Online (Sandbox Code Playgroud) 我不得不这样做:
def createpost(request):
if request.method == 'POST':
form = PostForm(request.POST)
if form.is_valid():
titlee = form.cleaned_data['title']
contentt = form.cleaned_data['content']
post = Post(title=titlee,content=contentt,created='2012-01-06',modified='2012-01-06')
post.save()
return render_to_response('createpost.html', {"form": form}, context_instance=RequestContext(request))
Run Code Online (Sandbox Code Playgroud)
有没有办法获得这样的形式价值post = Post(form) ; post.save()我不想像这样单独获得价值:titlee = form.cleaned_data['title']
任何的想法?
我正在做的事情:
url(r'^confirmemail/[a-bA-z0-9]+/', 'blog.views.confirmemail'),
Run Code Online (Sandbox Code Playgroud)
确切的网址是这样的:http://127.0.0.1:8000/confirmemail/tubwp2n0a6或http://127.0.0.1:8000/confirmemail/tubwp2n0a6/
字符串参数的长度为十(10).
如何在urls.py中写入该url?