有人可以告诉我如何设置这些复选框进行检查?我确信它很简单,但经过一个小时的尝试后我觉得我需要问一下!谢谢!
= form_tag movies_path, :id => 'ratings_form', :method => :get do
Include:
- @all_ratings.each do |rating|
= rating
= check_box_tag "ratings[#{rating}]",
= submit_tag 'Refresh', :id => 'ratings_submit'
Run Code Online (Sandbox Code Playgroud) 我希望在rails上的ruby中使用正则表达式,从而删除给定文本中的所有html标记及其内容.
例如,如果我的文字是:-INPUT: -
<span id="span_is"><br><br><u><i>Hi</i></u></span>
Run Code Online (Sandbox Code Playgroud)
那么它应该只显示OUTPUT应该如下: -
Hi
Run Code Online (Sandbox Code Playgroud)
总之,我想要正则表达式或删除<>的函数以及<>之间的任何内容.
感谢和问候,
Salil Gaikwad
我想在我的应用程序中搜索以下数据的搜索功能
topic_id tag
1 cricket
1 football
2 football
2 basketball
3 cricket
3 basketball
4 chess
4 basketball
Run Code Online (Sandbox Code Playgroud)
现在当我搜索术语cricket AND footballo/p应该是
topic_id
1
Run Code Online (Sandbox Code Playgroud)
当我搜索术语cricket OR footballo/p应该是
topic_id
1
2
3
Run Code Online (Sandbox Code Playgroud)
我尝试下面的事情
为了和
select topic_id from table_name where tag like "%cricket%" and topic_id in (select topic_id from table_name where tag like "%football%")
Run Code Online (Sandbox Code Playgroud)
为或
select topic_id from table_name where tag like "%cricket%" OR tag like "%football%"
Run Code Online (Sandbox Code Playgroud)
我的问题是当用户搜索cricket AND football AND basketball AND chess我的查询变得非常可悲时
对此有任何简单的解决方案.我也试过GROUP_CONCAT但是徒劳无功
我想使用Javascript禁用tinymce编辑器.实际上,我有两个单选按钮:1)On和2)Off.
当用户选择Off单选按钮时,我的tinymce编辑器应该是readonly/disabled&当用户选择On单选按钮时,我的tinymce编辑器应该是enabled.
我怎样才能做到这一点?
编辑: - (因为它不能在IE8中工作)
tinyMCE.init({
force_p_newlines : false,
force_br_newlines : false,
forced_root_block : false,
convert_newlines_to_brs: false,
// Not to add br elements.
remove_linebreaks : true,
mode : "textareas",
theme : "advanced",
plugins : "safari",
convert_urls : false,
width : "560",
height : "15",
theme_advanced_buttons1 : "fontselect,fontsizeselect, separator, bold,italic,underline,separator,forecolor,backcolor,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left", extended_valid_elements : "a[name|href|target|title|onclick],img[class|src| border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]"
}); …Run Code Online (Sandbox Code Playgroud) 我想重定向到另一个页面并且焦点应该放在一些DIVid上,让我们说'some-div-id'.我试过跟随
$location.path('/' + $scope.config_path.school + '/' +
$routeParams.someUrl + '/#some-div-id')
Run Code Online (Sandbox Code Playgroud)
这工作正常,但它首先将#更改为%23赞
/%23some-div-id #If '#' is not already present in the URL
/%23some-div-id#some-div-id #If '#' is laready present in the URL
/#some-div-id
Run Code Online (Sandbox Code Playgroud)
我也试过跟随
$location.path('/' + $scope.config_path.school + '/' +
$routeParams.someUrl + '/').hash('some-div-id')
Run Code Online (Sandbox Code Playgroud)
它正在创建一个正确的URL,但不会向下滚动到DIV带有idsome-div-id
EDITED
app.run(function($rootScope, $location, $anchorScroll, $routeParams) {
$rootScope.$on('$routeChangeSuccess', function(newRoute, oldRoute) {
setTimeout(function() {
if ($location.hash()) {
$anchorScroll($location.hash());
}
});
});
})
app.controller('MainCntrl', function($scope, $location, $anchorScroll, $routeParams) {
});
Run Code Online (Sandbox Code Playgroud)
此外,我试图$location.path和$location.url
我有以下文件lib/a/b/c.rb
class a::b::c
def request(env)
#some code here
end
end
Run Code Online (Sandbox Code Playgroud)
现在我使用的是rubocop风格
Style/ClassAndModuleChildren:
Enabled: true
Run Code Online (Sandbox Code Playgroud)
我为此获得了rubocop的进攻
lib/a/b/c.rb:1:7: C: Use nested module/class definitions instead of compact style.
class a::b::c
Run Code Online (Sandbox Code Playgroud)
当我更新我的代码到以下的攻击得到修复
风格1
class a
class b
class c
def request(env)
#some code here
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
风格2
module a
module b
class c
def request(env)
#some code here
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
我想我应该使用Style 2我require 'a'在我的一个文件中使用.
请让我知道如何修复此类型和违法行为及其原因
我require 'digest/sha1'用来加密我的密码并保存到数据库中.在登录期间,我通过匹配保存在数据库中的加密密码进行身份验证,并再次加密,使用输入密码字段.截至目前一切正常,但现在我想做'忘记密码'功能.为此,我需要解密保存在数据库中的密码以找到原始密码.如何解密使用digest/sha1?或者有没有人知道任何支持加密和解密的算法?
我在rails上使用ruby,所以我需要Ruby方法来完成它.
我在浮动下有一个div:右边div.由于某种原因,上边距不能应用于第一个div.这是css
#over{
width:80%;
float:right;
color:#e68200;
}
#under{
clear:both;
background:url(../images/anazitisi.png) no-repeat;
margin:10px auto; /*does not work!!!*/
width:95px;
height:20px;
}
Run Code Online (Sandbox Code Playgroud)
有谁知道发生了什么?
我有以下模特
用户
has_many :users_contacts
has_many :contacts, through: :users_contacts
accepts_nested_attributes_for :contacts, allow_destroy: true
Run Code Online (Sandbox Code Playgroud)
联系
has_many :users_contacts
has_many :users, through: :users_contacts
accepts_nested_attributes_for :users_contacts, allow_destroy: true
Run Code Online (Sandbox Code Playgroud)
UsersContact
belongs_to :users
belongs_to :contacts
Run Code Online (Sandbox Code Playgroud)
我正在使用以下强参数
params.require(:user).permit(:id, :email,
contacts_attributes: [:id, :first_name, :last_name,
users_contacts_attributes: [:id, :contact_id, :user_id, :order]])
Run Code Online (Sandbox Code Playgroud)
我现在面临的问题是每当我更新与用户users_contacts_attributes如{CONTACT_ID:5,顺序为:5}它会创建两个记录一个与order: nil及其他与order: 5我在PARAMS获得订单.
我想跟随
不希望创建重复记录.
使用额外列保存记录在连接表中,即 order
我的参数类似于以下内容
{"id"=>4,
"email"=>"abc@xyz.com",
"contacts_attributes"=>
[{"id"=>150,
"first_name"=>"Pqr",
"is_shareable"=>true,
"users_contacts_attributes"=>[{"id"=>87, "user_id"=>4, "contact_id"=>150, "order"=>100}]
},
{"first_name"=>"Def",
"is_shareable"=>true,
"users_contacts_attributes"=>[{"user_id"=>4, "order"=>101}]
}
]
}
Run Code Online (Sandbox Code Playgroud) ruby many-to-many ruby-on-rails ruby-on-rails-4 accepts-nested-attributes
我有以下一段代码
@user = User.find(params[:id])
if (@user.activation_status == "active")
#some code here
@user.update_attribute('activation_status' ,'inactive') # Line 44
#send mail to user that his account is Acivated
else
end
Run Code Online (Sandbox Code Playgroud)
有没有机会Line 44失败?因为数据库内存已满或网络出现故障.在那种情况下会发生什么?如果这会产生问题,那么避免它的更好方法是什么?update_attribute失败后会返回什么?
ruby ×6
angularjs ×1
checkbox ×1
class ×1
css ×1
encryption ×1
haml ×1
html ×1
javascript ×1
many-to-many ×1
margin ×1
module ×1
mysql ×1
rubocop ×1
sql ×1
tinymce ×1
url ×1
url-routing ×1
wysiwyg ×1