我不知道为什么它不像示例那样重复.当我把以下代码用于这个表单时:
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :class => "form-horizontal" } ) do |f| %>
<%= f.input :user_name, :input_html => { :class => "span3" }, :hint => "just letters and numbers please." %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
现在它看起来像这样:

当我希望它像这样(这里的第一个例子:http://simple-form-bootstrap.plataformatec.com.br/articles/new).

问题在于生成的HTML.我的HTML是:
<div class="input string optional">
<label for="user_user_name" class="string optional"> User name</label>
<input type="text" size="50" name="user[user_name]" maxlength="25" id="user_user_name" class="string optional span3">
<span class="hint">no spaces or special characters, just letters and numbers please</span>
</div>
Run Code Online (Sandbox Code Playgroud)
和Simple_forms …
我不能让我的图标显示出来.它被调用favicon.ico并在公共目录(文件夹)中.我的开发日志显示了favicon没有问题.我把链接放在我的应用程序布局中:
<!DOCTYPE html>
<html>
<head>
<%= csrf_meta_tag %>
<%= favicon_link_tag "/favicon.ico" %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
</head>
<body>
<%= yield %>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但它仍然没有出现在Firefox中.我用Firefox清除了缓存,我也尝试<%= favicon_link_tag %>了.我没有尝试过制作但你甚至可以在localhost中看到它吗?我错过了什么?
UPDATE
所以它出现在Chrome中但不是Firefox.知道为什么吗?
我想过滤我的类的私有布尔值,所以它只显示非私有的资源,但它不适合我.(我极大地贬低了代码)
mapping do
indexes :private, type: "boolean"
indexes :name, type: "string"
end
end
def self.search(params)
tire.search(load: true, page: params[:page], per_page: 20) do
query { string params[:query] } if params[:query].present?
# So far I've tried...
# filter :bool, :private => ["false"]
# filter :bool, private: false
end
end
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
我有以下模型和方法:
class UserPrice < ActiveRecord::Base
attr_accessible :price, :purchase_date,
def self.today
where(:purchase_date => Date.today)
end
def self.yesterday
where(:purchase_date => Date.yesterday)
end
Run Code Online (Sandbox Code Playgroud)
为什么在我的表格上,如果我给我的date_select字段1/4/2012 :purchase_date(yesterday方法)它也算作今天(today方法),如果我给它1/5/2012(今天)它是零?
PS我正在使用Rails 3.0.10和PostgreSQL.
更新
这是我的控制台返回:
$ rails console --s
Loading development environment in sandbox (Rails 3.0.10)
Any modifications you make will be rolled back on exit
irb(main):001:0> Date.today
=> Wed, 04 Jan 2012
irb(main):002:0> Time.now
=> 2012-01-04 21:28:07 -0500
irb(main):003:0> Time.zone.now
=> Thu, 05 Jan 2012 02:28:18 UTC +00:00
irb(main):004:0> Date.yesterday
=> Wed, …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序上安装了Sphinx和Thinking Sphinx 2.0.5,当我不断尝试运行命令时,rake ts:index它给了我这个错误:
rake aborted!
undefined method `indexes' for #<Riddle::Configuration:0x41b57b0>
Run Code Online (Sandbox Code Playgroud)
是在谈论我的Product模特吗?
class Product < ActiveRecord::Base
attr_accessible :name
validates_presence_of :name
define_index do
indexes :name
end
end
Run Code Online (Sandbox Code Playgroud)
为什么我得到这个,我该如何解决?
对于我的表格我使用我的Product模型:
class Product < ActiveRecord::Base
attr_accessible :purchase_date, :send_to_data
end
Run Code Online (Sandbox Code Playgroud)
在我的表单上:purchase_date,当我创建多个产品时,我还能正常工作,但也想让radio_button_tag做同样的事情:
<%= form_tag create_multiple_products_path, :method => :post do %>
<%= date_select("product", "purchase_date") %>
<%= radio_button_tag(:send_to_data, 1) %>
<%= radio_button_tag(:send_to_data, 0) %>
<% @products.each_with_index do |product, index| %>
<%= fields_for "products[#{index}]", product do |up| %>
<%= render "fields", :f => up %>
<% end %>
<% end %>
<%= submit_tag "Done" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这对我不起作用,我的数据库没有标记为false或true.
我认为问题在于"send_to_data".不同于"purchase_date"它没有找到对象(产品).
{"product"=>{"purchase_date(2i)"=>"12", "purchase_date(3i)"=>"11", "purchase_date(1i)"=>"2011"},
"send_to_data"=>"1",
"products"=>{"0"=>{"product_name"=>"Test", "price"=>"23", "product_store"=>"13", …Run Code Online (Sandbox Code Playgroud) 我试图link_to用html 传递一个块,但无法得到它.我尝试了其他一些没有运气的方法,所以我将使用我的原始代码:
<% link_to survey_path(survey), :class => "button" do %>
<span>add questions to <%= survey.name %></span>
<% end %>
Run Code Online (Sandbox Code Playgroud)
这并没有表明:class.
需要纠正的是什么?
我有一个Rails 3.2.8应用程序,我不想推送我的spec文件夹并test登录到Heroku.我该怎么做?用staging遥控器怎么样?
谢谢.
我不知道出了什么问题.好像我做得对.我正在尝试在我的应用程序中使用Font Awesome,但字体不会出现.我有一个名为的文件夹fonts,在我application.rb的行中包括:
class Application < Rails::Application
# Enable the asset pipeline
config.assets.enabled = true
# This line
config.assets.paths << Rails.root.join("app", "assets", "fonts")
Run Code Online (Sandbox Code Playgroud)
比,而不必附带字体-真棒2个CSS文件(CHANGED见下文)(并不需要IE7一个)我只是把主要的CSS我的脑海中application.css.比我更改网址以检测字体文件.
@font-face {
font-family: "FontAwesome";
src: url('<%= asset_path('fontawesome-webfont.eot') %>');
src: url('<%= asset_path('fontawesome-webfont.woff') %>') format('woff'),
url('<%= asset_path('fontawesome-webfont.ttf') %>') format('truetype'),
url('<%= asset_path('fontawesome-webfont.svg#FontAwesome') %>') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
我关闭了服务器并在每次更改代码后重新启动但仍然没有好处.我错过了什么?
更新:
我没有使用SASS或LESS.也许@font-face是问题?我之前从未见过这种类型的代码.
UPDATE
我现在正在使用font-awesome.css文件.但它没有出现在我的源代码中.
<head>
<link href="/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css">
<link href="/assets/chosen.css?body=1" media="screen" …Run Code Online (Sandbox Code Playgroud)