我收到此错误:
Routing Error
uninitialized constant RegistrationsController
Run Code Online (Sandbox Code Playgroud)
这是我的日志:
Started GET "/registrants/1/registrations/new" for 127.0.0.1 at 2012-07-03 00:55:44 -0500
ActionController::RoutingError (uninitialized constant RegistrationsController):
Rendered /.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (8.5ms)
Run Code Online (Sandbox Code Playgroud)
这是我的routes.rb的一部分是合适的:
registrant_registrations GET /registrants/:registrant_id/registrations(.:format) {:action=>"index", :controller=>"registrations"}
POST /registrants/:registrant_id/registrations(.:format) {:action=>"create", :controller=>"registrations"}
new_registrant_registration GET /registrants/:registrant_id/registrations/new(.:format) {:action=>"new", :controller=>"registrations"}
edit_registrant_registration GET /registrants/:registrant_id/registrations/:id/edit(.:format) {:action=>"edit", :controller=>"registrations"}
registrant_registration GET /registrants/:registrant_id/registrations/:id(.:format) {:action=>"show", :controller=>"registrations"}
PUT /registrants/:registrant_id/registrations/:id(.:format) {:action=>"update", :controller=>"registrations"}
Run Code Online (Sandbox Code Playgroud)
这是我的注册控制器,位于/app/controllers/portal/registrations_controller.rb:
class Portal::RegistrationsController < ApplicationController
def create
@registrant = current_member.registrants.find(params[:registrant])
@registration = @registrant.registrations.build
respond_to do |format|
if @registration.save
format.html { redirect_to root_path, :notice => …Run Code Online (Sandbox Code Playgroud) 我想复制一下:
<a href="thepledge.html" class="btn btn-inverse btn-mini btn-ten"><i class="icon-pencil"></i>Take The Pledge</a>
Run Code Online (Sandbox Code Playgroud)
我试过这个:
<%= link_to("Take the pledge", root_path, :class => "btn btn-inverse btn-mini btn-ten") do %>
<i class="icon-pencil"></i>
<% end %>
Run Code Online (Sandbox Code Playgroud)
但它给了我这个错误:
NoMethodError at /
undefined method `stringify_keys' for "/":String
Run Code Online (Sandbox Code Playgroud)
在link_to通话中.
思考?
在我的开发环境中,当我在我的应用程序上发出请求时,我看到了这样的AREL和SQL查询:
Started GET "/products/20" for 127.0.0.1 at 2012-12-31 19:18:40 -0500
Processing by ProductsController#show as HTML
Parameters: {"id"=>"20"}
Category Load (0.2ms) SELECT "categories".* FROM "categories" LIMIT 6
Product Load (0.1ms) SELECT "products".* FROM "products" WHERE "products"."id" = ? LIMIT 1 [["id", "20"]]
Product Load (0.3ms) SELECT "products".* FROM "products"
Vendor Load (0.2ms) SELECT "vendors".* FROM "vendors" WHERE "vendors"."id" = 11 LIMIT 1
Product Load (0.2ms) SELECT "products".* FROM "products" WHERE "products"."vendor_id" = 11
(0.2ms) SELECT COUNT(*) FROM "categories" INNER JOIN "category_products" …Run Code Online (Sandbox Code Playgroud) 所以我刚升级到FontAwesome 4.0.此更改的一部分是引用图标的方式.
你不能再这样做了:<i class="icon-beer"></i>.
现在......你不得不更换icon同fa-,所以上面现在看起来是这样的:
<i class="fa fa-beer"></i>
因此,我决定用icon-我的项目替换所有引用fa fa-.
其中包括缓存文件,转储文件以及所有样式表,视图等.
现在......当我尝试加载任何页面时,我收到此错误:
ArgumentError at /
dump format error for symbol(0x69)
Run Code Online (Sandbox Code Playgroud)
日志看起来像这样:
Completed 500 Internal Server Error in 1060ms
ArgumentError - dump format error for symbol(0x69):
activesupport (3.2.14) lib/active_support/cache.rb:587:in `value'
activesupport (3.2.14) lib/active_support/cache.rb:324:in `block in read'
activesupport (3.2.14) lib/active_support/cache.rb:520:in `instrument'
activesupport (3.2.14) lib/active_support/cache.rb:315:in `read'
sprockets (2.2.2) lib/sprockets/caching.rb:70:in `cache_get'
sprockets (2.2.2) lib/sprockets/caching.rb:45:in `cache_get_hash'
sprockets (2.2.2) lib/sprockets/caching.rb:15:in `cache_asset'
sprockets (2.2.2) lib/sprockets/index.rb:92:in `build_asset'
sprockets …Run Code Online (Sandbox Code Playgroud) 我刚刚在rake db:migrate第一次部署Rails 4应用程序时在Heroku上成功运行:
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.7124
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
Migrating to DeviseCreateUsers (20131223210005)
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
-> 0.0431s
-- add_index(:users, :email, {:unique=>true})
-> 0.0093s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0185s
== DeviseCreateUsers: migrated (0.0716s) =====================================
Migrating to AddNameToUsers (20131223210006)
== AddNameToUsers: migrating =================================================
-- add_column(:users, :name, :string)
-> 0.0060s
== AddNameToUsers: migrated (0.0062s) ========================================
Migrating to …Run Code Online (Sandbox Code Playgroud) 我想copyright (c) 2014在我的页脚中创建一个通知.
但我希望它能在所有年/月/天内循环,而不必改变它.
我有一个_footer.html.erb部分我在做这个.
显而易见的答案就是说<%= Time.now.year %>.
这意味着每次加载视图时,都必须在最后执行Ruby调用.考虑到这将出现在网站的每个页面上并且必须为每个单独的负载进行Ruby调用,这看起来有点贵.
是否有更轻量级/简化的方式,可能缓存值并从缓存中显示?
这是我现在得到的错误:
Started GET "/" for 127.0.0.1 at 2014-08-29 06:37:21 -0500
ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by PostsController#index as HTML
Post Load (0.8ms) SELECT "posts".* FROM "posts" ORDER BY created_at desc
Rendered shared/_color.html.erb (0.6ms)
Rendered shared/_color.html.erb (0.1ms)
Rendered shared/_color.html.erb (0.3ms)
Rendered posts/index.html.erb within layouts/application (47.4ms)
Completed 500 Internal Server Error in 264ms
Sprockets::FileNotFound - couldn't find file 'jquery'
(in /app/assets/javascripts/application.js:13):
Run Code Online (Sandbox Code Playgroud)
这是我的application.js,
//= require jquery <--- This is Line 13
//= require jquery_ujs
//= require jquery-ui
//= …Run Code Online (Sandbox Code Playgroud) My devise emails work fine in development.
But now that I have pushed to Heroku and am using the sendgrid add-on, they don't get sent. I don't get an error. It seems like it is sent just fine, it is just that it never actually reaches my inbox.
This is my config/environment/production.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.default_url_options = { :host => 'http://myapp.herokuapp.com' }
config.action_mailer.smtp_settings = {
:user_name => ENV["SENDGRID_USERNAME"],
:password …Run Code Online (Sandbox Code Playgroud) 假设我有一个如下所示的数组:
array1 = button.attr('id').split('-');
["slider", "step", "value", "speed", "rebecca", "nitzsche", "st", "george", "s", "college"]
Run Code Online (Sandbox Code Playgroud)
我想要做的就是把所有元素speed都array1[3]放在后面,所以一切都在结束之后,把它全部变成1个用a分隔的字符串,-如下所示:rebecca-nitzsche-st-george-s-college.
我该怎么做呢?
我有一个Profile模型,具有以下内容:
has_many :transcripts, dependent: :destroy
accepts_nested_attributes_for :transcripts, allow_destroy: true
Run Code Online (Sandbox Code Playgroud)
在我的Transcript模型上,我有以下内容:
include TranscriptUploader[:attachment]
Run Code Online (Sandbox Code Playgroud)
这是一个Shrine Uploader mount.
在我app/views/profile/_form.html.erb,我有以下内容:
<div id="transcripts" class="text-center">
<% if @profile.transcripts.any? %>
<% @profile.transcripts.each do |transcript| %>
<%= link_to "Click to view Transcript", transcript.url %>
<% end %>
<% end %>
<%= f.simple_fields_for :transcripts do |transcript| %>
<%= render 'transcript_fields', f: transcript %>
<% end %>
<br />
<div class="links">
<%= link_to_add_association 'Add Transcript', f, :transcripts, class: "btn btn-success add-transcript-button" %>
</div>
</div> …Run Code Online (Sandbox Code Playgroud) heroku ×3
ruby ×2
css ×1
devise ×1
javascript ×1
jquery ×1
postgresql ×1
sendgrid ×1
turbolinks ×1