当"Recaptcha"发现错误的关键字时,设计完全返回闪光警报.
但在我将设计版本从1.4.7更新到2.1.0之后,它总是说"未定义的方法`render_with_scope'代表#"
有没有人有同样的问题?这是因为设计2.1.0与"Recaptcha"的兼容性吗?
我现在正在抓住所有用户.
但是,我想排除未确认的用户.
他们的confirmed_at属性是零.
我怎么能够?
@search = User.search do
fulltext params[:search]
paginate :page => params[:page], :per_page => 10
end
@users = @search.results
Run Code Online (Sandbox Code Playgroud) 如果用户在体内输入youtube url并保存记录,我想在视图中显示其缩略图.
有什么好技巧吗?还是好宝石?
在url中输入的样本:
http://www.youtube.com/watch?v=qrO4YZeyl0I
Run Code Online (Sandbox Code Playgroud) 我有一个名为的模型Community,它有一个名为的列name
我name在子域中使用它.
例如,当用户访问时http://rockstar.test-sample.com,它显示的内容与之相同http://test-sample.com/community/rockstar
显然,这name不应该www
www如果我说明的话,我怎么能禁止models/community.rb?
我尝试像这样编码
<ImageView android:id="@+id/ivIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_btn_speak_now" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item0" />
Run Code Online (Sandbox Code Playgroud)
但输出是这样的。不在同一行:(

我的整个xml代码就是这样的。
(icon) item将是一个集合,用户将单击它来继续活动。
所以我需要将它们分组在一起。
<LinearLayout style="@style/behindMenuScrollContent"
android:paddingTop="25dp" >
<TextView
style="@style/behindMenuItemTitle"
android:text="Subject" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item0" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item1" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item2" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item3" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item4" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item5" />
<TextView
style="@style/behindMenuItemTitle"
android:text="Subject2" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item6" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item7" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item8" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item9" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item10" />
<Button
android:id="@+id/behind_btn"
style="@style/behindMenuItemLabel"
android:text="BUTTON" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
更新:我不需要图标和文本之间的边距,但只需要左侧的边距! …
@comments共有10条记录,id ASC现在排序.
我想简单地改变订单,所以我编码了@comments = @comments.reverse
但我收到此错误消息
ActionView::Template::Error (undefined method `total_count'
<%= page_entries_info(@comments, :entry_name => 'comment').html_safe %>
Run Code Online (Sandbox Code Playgroud)
如果我倒退并保持原样@comments = @comments,那就不会有任何问题.为什么?我如何按顺序排序created_at DESC?
@comments = Comment.where(:user_id => user_ids, :commentable_type => commentable)
if params[:page].blank?
params[:page] = ((@comments.count - 1)/10) + 1
@comments = @comments.page(params[:page]).per(10)
else
@comments = @comments.page(params[:page]).per(10)
end
@comments = @comments.reverse
Run Code Online (Sandbox Code Playgroud) 当视图将参数传递给控制器时,控制器以某种方式获得所有争论的nil.
任何人都可以解决这个问题?谢谢!
我没有名为"消息"的模特
控制器/ messages_controller.rb
def deliver
recipient = User.find_by_username(params[:recipient])
subject = params[:subject]
body = params[:body]
current_user.send_message(recipient, body, subject)
redirect_to :controller => 'messages', :action => 'received'
flash[:notice] = "message sent!"
end
Run Code Online (Sandbox Code Playgroud)
视图/消息/ new.html.erb
<%=form_for :messages, url: url_for( :controller => :messages, :action => :deliver ) do |f| %>
<div class="field">
<%= f.label :subject %><br />
<%= f.text_field :subject %>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_field :body %>
</div>
<div class="actions">
<%= f.submit %>
<% end %>
Run Code Online (Sandbox Code Playgroud) 我想传递两个参数,如topic和icon_photo.
我怎样才能做到这一点?
未定义的方法`icon_photo?'
我用下面的代码得到了这个错误.
视图
<div class="Topic">
<% @community.topics.each do |topic| %>
<%= render 'topics/topic', :topic => topic, :icon_photo => topic.user.profile.avatar %>
<% end %>
</div>
Run Code Online (Sandbox Code Playgroud) 在我的情况下,即使有验证错误,它也不会显示验证错误消息.
例如,我将这两列保留为空,并确保键入了验证字.然后,如果我尝试创建新记录.它不会显示验证错误:(它返回到表单但没有消息.
我一直在这个项目中一直使用验证错误消息,我从来没有遇到过这个问题.
任何人都可以在这里找到问题?
在主题模型中验证
validates :title,
:presence => {:message => "can't be empty" },
:uniqueness => {:message => "choose unique title" },
:length => { :maximum => 20, :message => "must be less than 20 characters" }
validates :body,
:presence => {:message => "can't be empty" },
:length => { :maximum => 500, :message => "must be less than 20 characters" }
Run Code Online (Sandbox Code Playgroud)
形成
<%= form_for([@community, @topic]) do |f| %>
.....
<%= button_tag( :class => "btn btn-primary") do %>
Create …Run Code Online (Sandbox Code Playgroud)