我正在我的应用程序中使用引用机制,例如,应该可以在注释表单中键入#26,以便引用该主题的注释26.
要检查用户是否想要首先引用一个或多个注释,我在current_user.comments.build之后和@ comment.save之前添加了一个if条件.
但是,只是为了使我的问题更通用,更容易适应:
if @comment.content.include?(/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i)
Run Code Online (Sandbox Code Playgroud)
我想要这样的东西.该示例用于检查评论的内容是否包含电子邮件.但从逻辑上讲,我得到一个"无法将regexp转换为字符串"错误.
你怎么做包括?使用正则表达式的rails中的方法?那么,检查文本是否包含某个正则表达式格式的字符串?
或者控制器是这种正则表达式操作的错误位置?
我想知道是否有人有关于新的YouTube卡(替换旧的注释)的API(如果它存在?)的任何信息或新闻.
有没有beta api信息呢?
我是指这个: 
谢谢您的帮助
在我的演示有点应用程序
case WM_CLOSE:
DestroyWindow(hndl);
return 0;
Run Code Online (Sandbox Code Playgroud)
和
case WM_CLOSE:
PostQuitMessage(0);
return 0;
Run Code Online (Sandbox Code Playgroud)
照着做.在给每个人打电话时窗帘背后有什么不同?DestroyWindow更直接,PostQuitMessage必须通过getmessage循环返回false吗?
在请求我的示例应用程序的主页时,我收到以下错误消息(遵循Michael Hartl的教程第11章):
"页面#home中的ActiveRecord :: HasManyThroughSourceAssociationNotFoundError"
"无法在模型关系中找到源关联:followed_id.尝试'has_many:follows_users,:through =>:relationships,:source =>'.它是以下之一:追随者还是:跟着?"
这真的很奇怪,因为我完全按照教程的说明进行操作.我甚至复制粘贴每个代码片段.
我的用户模型(摘录):
class User < ActiveRecord::Base
has_many :relationships, foreign_key: "follower_id", dependent: :destroy
has_many :followed_users, through: :relationships, source: "followed_id"
has_many :reverse_relationships, foreign_key: "followed_id", class_name: "Relationship", dependent: :destroy
has_many :followers, through: :reverse_relationships, source: :follower
Run Code Online (Sandbox Code Playgroud)
我的关系模型:
class Relationship < ActiveRecord::Base
attr_accessible :followed_id
belongs_to :follower, class_name: "User"
belongs_to :followed, class_name: "User"
validates :follower_id, presence: true
validates :followed_id, presence: true
end
Run Code Online (Sandbox Code Playgroud)
我的迁移文件:
class CreateRelationships < ActiveRecord::Migration
def change
create_table :relationships do |t|
t.integer :follower_id
t.integer :followed_id
t.timestamps …Run Code Online (Sandbox Code Playgroud) 我有一个运行良好的博客子域,但是,登录与所有子域分离,因此,如果用户登录其cookie,则仅在非子域页面上有效.如何设置我的应用程序以使cookie在所有子域和普通页面中有效?
我解决了这个主题:在Rails中的子域之间共享会话(cookie)?但不幸的是没有成功.我甚至尝试了一步一步的机架中间件方法,但没有成功.
我正在使用Rails 3.2.13.
任何帮助赞赏!:)
cookies subdomain ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2
我有一个关于Bootstrap折叠功能的问题.我很确定我忽略了一些非常明显或容易修复的东西,但我用Google搜索了很多并且使用了代码,但没有成功.
我有一个"帐户设置"页面,其中用户的所有帐户信息以类似表格的格式显示,最后一个表格列的表格单元格始终包含"编辑"按钮以编辑该信息.当人们点击"编辑"时,编辑表格将在该表格行的正下方展开.
我按照http://twitter.github.com/bootstrap/javascript.html#collapse中的方案,崩溃函数本身工作正常,但问题是每个表单总是扩展到我的表上方,无论我点击哪个编辑按钮上.我截了当它的样子.http://imageshack.us/photo/my-images/834/problemyn.png/而不是在整个表格之上,我希望它在特定行的下方展开,将下面的行向下推.
这是我的代码:
<table class="table">
<tbody>
<tr>
<td>Username</td>
<td><%= @user.name %></td>
<td><button class="btn btn-danger" data-toggle="collapse" data-target="#username">Edit</button></td>
</tr>
<div id="username" class="collapse">
<div class="row">
<div class="span6 offset3">
<%= form_for(@user) do |form| %>
<%= render 'shared/error_messages', object: form.object %>
<%= form.label :name, "Change Username" %>
<%= form.text_field :name %>
<%= form.submit "Save changes", class: "btn btn-primary" %>
<% end %>
</div>
</div>
</div>
<tr>
<td>Email</td>
<td><%= @user.email %></td>
<td><button class="btn btn-danger" data-toggle="collapse" data-target="#email">Edit</button></td>
</tr>
<div id="email" class="collapse">
<div …Run Code Online (Sandbox Code Playgroud) 不知道我做错了什么,但是按照本教程http://sixrevisions.com/css/font-face-guide/,我在使其工作时遇到问题。
我的代码位于 style.css 顶部:
@font-face {
font-family: 'chunkfiveregular';
src: url('http://careerteam.de/wp-content/themes/theme1383/css/chunkfive-webfont.eot');
src: url('http://careerteam.de/wp-content/themes/theme1383/css/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
url('http://careerteam.de/wp-content/themes/theme1383/css/chunkfive-webfont.woff') format('woff'),
url('http://careerteam.de/wp-content/themes/theme1383/css/chunkfive-webfont.ttf') format('truetype'),
url('http://careerteam.de/wp-content/themes/theme1383/css/chunkfive-webfont.svg#chunkfiveregular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
我的根文件夹中包含所有文件。
我后来通过以下方式调用字体系列:
#man_translated {
font-size: 26px;
font-style: italic;
line-height: 28px;
font-family:chunkfiveregular;
}
Run Code Online (Sandbox Code Playgroud)
我在wordpress中,我使用的模板有一个预设的h1、h2、h3字体画布样式,将每个单词转换为dakota手写字体的png。也许模板中的这个核心设置与我的 onthefly javascript id/css 更改相冲突。
associations ×1
c++ ×1
cookies ×1
css ×1
expand ×1
font-face ×1
fonts ×1
html-table ×1
regex ×1
relationship ×1
ruby ×1
string ×1
subdomain ×1
winapi ×1
windows ×1
wordpress ×1
youtube ×1
youtube-api ×1