我在stylesheets/custom.css.scss中有以下内容
@import "bootstrap";
.navbar-inverse .navbar-brand {
color: #f0ad4e;
}
Run Code Online (Sandbox Code Playgroud)
以及我的布局/ application.html.erb中使用的布局/ _header.html.erb中的以下内容
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand">....... etc..
Run Code Online (Sandbox Code Playgroud)
为什么我的导航栏品牌不会改变颜色!这让我疯狂!
在我的检查员中,我看到以下内容:
.navbar-inverse .navbar-brand {
color: #999999;
}
Run Code Online (Sandbox Code Playgroud)
所以它没有生效,任何想法?
是否可以在不同的端口运行相同的项目或应用程序?假设,我有项目/应用程序博客,我想在两个不同的端口立即在这个项目中运行.当我运行服务器即rails server,然后它运行在端口3000.再次,在下一个终端点击,我尝试相同的项目,但在不同的端口,即rails server -p 3001,但它不运行?
有没有其他方法可以在localhost服务器上的不同端口中以不同的方式运行相同的项目?
我有一系列哈希:
@operating_systems = [
{"title"=>"iPhone", "value_percent"=>"42.6"},
{"title"=>"Windows 7", "value_percent"=>"21.3"},
{"title"=>"Android", "value_percent"=>"12.8"},
{"title"=>"Mac OS X", "value_percent"=>"8.5"},
{"title"=>"Windows 8.1", "value_percent"=>"6.4"},
{"title"=>"Windows XP", "value_percent"=>"4.3"},
{"title"=>"Linux", "value_percent"=>"2.1"},
{"title"=>"Windows Vista", "value_percent"=>"2.1"}
]
Run Code Online (Sandbox Code Playgroud)
并想要创建以下哈希:
{"iphone" => "42.6", "windows 7" => "21.3", ... "windows vista" => "2.1"}
Run Code Online (Sandbox Code Playgroud)
完成此任务的最佳方法是什么?
我正在使用ruby 2.0.0这是我的控制器..
@mail_msg = @store_items.where(id: params[:button_id]).first.email_confirmation_text
p "-------------------------"
p @mail msg
p @mail_msg.html_safe
Run Code Online (Sandbox Code Playgroud)
这是我的控制台(终端)输出
"-------------------------"
"<p>You have purchased Spice It Up. Points have been redeemed from your main account.</p>"
"<p>You have purchased Spice It Up. Points have been redeemed from your main account.</p>"
Run Code Online (Sandbox Code Playgroud)
我在我的控制台中获得的是相同的.我无法逃脱html标签.
我在视图中有这个值..在我的视图页面中
<%= @mail_msg.html_safe %>
Run Code Online (Sandbox Code Playgroud)
仍然没有工作..
请帮忙
而不是标准的显示,编辑,删除,我在views/users/index.html.erb中有以下内容
<td>
<%= link_to user, class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-search"></span>
<% end %>
</td>
<td>
<%= link_to edit_user_path(user), class: 'btn btn-default' do %>
<span class="glyphicon glyphicon-pencil"></span>
<% end %>
</td>
<td>
<%= link_to user, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger' do %>
<span class="glyphicon glyphicon-remove"></span>
<% end %>
</td>
Run Code Online (Sandbox Code Playgroud)
如何在应用程序中的所有其他模型中重复使用此代码?
ruby-on-rails twitter-bootstrap ruby-on-rails-4 ruby-on-rails-4.1
Rails 4 + JS + jQuery
如何禁用使用相同类的链接的右键单击。
<% @schedule_hash.values.each do |schedule| %>
<%= link_to "Cancellation policy", {:controller => 'web', :action => 'get_cancellation_policies', :operator_id => schedule["bus_schedules"].operator_id}, :onclick => "", :class => "canc_policy", :id => "canc_policy#{schedule["bus_schedules"].operator_id}", :remote => true %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
假设@ schedule_hash.count = 7,那么7次链接将具有相同的类名。
所以我正在使用这个脚本
<script type="text/javascript">
$(document).ready(function(){
document.getElementsByClassName('canc_policy')[0].oncontextmenu = new Function ("return false");
});
$(document).ready(function()
{
$('.canc_policy').bind('click', function(e)
{
if (e.metaKey || e.ctrlKey )
{
e.metaKey = e.ctrlKey;
return false;
}
})
$(".canc_policy").mousedown(function(e) {
if( e.which == 2 …Run Code Online (Sandbox Code Playgroud) 我正在将项目从rails 3升级到rails 4.当我切换到rails 4时,我在日志中遇到了这个错误.但是我没有把这个方法传递给任何论据.
ActionView::Template::Error (wrong number of arguments (1 for 0)):
1: <div id="titles_list">
2:
3: <div id="admin_title_select_group">
4: <% table_group = select_table_group %>
5: <%= select_tag 'selected_group', options_for_select(table_group, by_default_selected_group) %>
6: </div>
7:
app/helpers/admin/titles_helper.rb:14:in `select_table_group'
app/views/admin/titles/index.html.erb:4:in `_app_views_admin_titles_index_html_erb__3791160006166460542_70179046974220'
lib/metal/search_store.rb:17:in `call'
Run Code Online (Sandbox Code Playgroud)
index.html.erb
<div id="titles_list">
<div id="admin_title_select_group">
<% table_group = select_table_group %>
<%= select_tag 'selected_group', options_for_select(table_group, by_default_selected_group) %>
</div>
...
Run Code Online (Sandbox Code Playgroud)
这是我的帮手方法:
module Admin::TitlesHelper
def select_table_group
g = [[I18n.t('admin.tpgn.select_group'),0]]
g += TitleProviderGroupName.all(:order => :name).collect{|t| [ t.name, t.id ]}
end
def by_default_selected_group
if …Run Code Online (Sandbox Code Playgroud) 我想在Rails中编写一个带有检查条件的按钮标签,该条件会附加一个类.
我这样写了..但导致语法错误.
<%= button_tag "On", {class: 'notification-btn notification-on btn btn-xs'+' active' if current_user.notification == true} %>
Run Code Online (Sandbox Code Playgroud)
active仅当current_user.notification为true时,才需要存在此类
我使用了以下问题,从字符串中删除"www","http://",以从我的网址中删除HTTP和HTTPS.现在我想删除url末尾的路径,似乎无法获得模式.这是我尝试使用的代码:
str = str.sub(/^https?\:\/\//, '').sub(/^www./,'').sub(/^\/*/,'')
Run Code Online (Sandbox Code Playgroud)
前两个.sub按预期工作并从URL中移除HTTP,但是路径即保留URL.从上面可以看出,我在第三个子程序中尝试了以下模式,但它没有删除URL末尾的路径.什么模式将删除基本URL后的所有字符?HTTPSwww.http://URL/path/to/remove//^\/*/
我在这个问题上找不到其他答案对我有帮助.
我有一个条款和条件框,并想验证它是否在创建时进行了检查.
在我的模型中:
validates :terms_and_conditions, :on => :create, acceptance: true, :allow_nil => false
Run Code Online (Sandbox Code Playgroud)
在我看来:
<%= f.check_box(:terms_and_conditions )%>
Run Code Online (Sandbox Code Playgroud)
无论是否check_box检查,它总是失败.我认为它实际上从未设置过该字段,问题在我看来,但我找不到它.
提交表单时记录.
Processing by Users::RegistrationsController#create as HTML
Parameters: {"utf8"=>"?", "authenticity_token"=>"xNNmGTWSV4hkj0rrlZeOq+AiTlJ9sc9+cAT1Sy0bjhc=", "user"=>{"email"=>"sdasdr@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "name"=>"", "surname"=>"", "country_id"=>"", "language"=>"", "description"=>"", "register_as_company"=>"1", "terms_and_conditions"=>"1"}, "commit"=>"Sign up"}
Unpermitted parameters: name, surname, country_id, language, description, register_as_company, terms_and_conditions
[1m[35m (0.1ms)[0m begin transaction
[1m[36mUser Exists (0.3ms)[0m [1mSELECT 1 AS one FROM "users" WHERE "users"."email" = 'sdasdr@gmail.com' LIMIT 1[0m
[1m[35m (0.1ms)[0m rollback transaction
[1m[36mCountry Load (0.2ms)[0m [1mSELECT "countries".* FROM "countries"[0m …Run Code Online (Sandbox Code Playgroud)