Rails

Rails creating schema_migrations - Mysql2::Error: Specified key was too long

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Rails 3.2.6 and Mysql 6.0.9 (but I have exactly the same error on MySQL 5.2.25) When I create new database ( rake db:create ) and then when I try to load the schema ( rake schema:load ) I get this error: Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`) After hours and hours of research I found these solutions: 1. Change MySQL variable innodb_large_prefix to true (or ON) This didn't work. I tried it on my Linux server, my Mac

how to implement bootstrap 4 and rails 5

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to ruby and I am trying to include bootstrap 4.0.0.alpha4 into rails 5.0.0. I have installed the gems bootstrap,bootstrap-sass, autoprefixer-rails and I have even used @import "bootstrap" in the application.css.sass, but still I am not getting the bootstrap on the page.I have a button on the view where I am trying to implement the bootstrap design. I have even tried it on different projects ut none of them works. Any help would be appreciated. Thanks. The codes are as shown below. Gem file source 'https://rubygems.org' # Bundle edge

Chrome Extension + Devise + Rails App - Making authenticated requests from extension?

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm building a chrome extension that facilitates the creation of contacts straight from the browser without needing to go to my devise-powered rails app itself. Contacts#Create requires authentication so I'm wondering how I can do send authenticated requests from the extension. I've enabled devise TokenAuthenticatable and so my users have an authtoken. I've written a method in my extensions js that posts to my rails app's contacts#create action. For testing, I've simply hard coded my own auth token in, which seems to work. But how can the

rails mongoid clear criteria

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Mongoid::Paranoia adds a default scope to the model which generates the criteria #<Mongoid::Criteria selector : {: deleted_at =>{ "$exists" => false }}, options : {}, class : Line , embedded : false > I can find deleted documents with Model.deleted which generates, #<Mongoid::Criteria selector : {: deleted_at =>{ "$exists" => true }}, options : {}, class : Line , embedded : false > How can i override this so i can search both deleted and non-deleted documents. PS Model.unscoped does not work 回答1: Try this(its kind of hack): class

undefined method `get&#039; for #&lt;RSpec::Core::ExampleGroup::Nested_1:0x00000106db51f8&gt;

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Anyone know how to get around this? On OSX, trying to get RSpec running with Rails 3.0.7. Full details at: https://gist.github.com/1017044 it "renders buttons_widgets partial" do get :buttons_widgets response.should render_template("buttons_widgets") end → rspec tools_model_spec.rb /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/version.rb:4: warning: already initialized constant STRING /Users/mm/.rvm/gems/ruby-1.9.2-p0@evergreen/bundler/gems/rspec-core-bea2366c817e/lib/rspec/core/metadata.rb

Ruby on Rails: Skipping 'validate_on_create' statement for seeds

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a 'validate_on_create' statement in one of my controllers that I would like all of my seed data to skip. What are some solutions so that the create statement in my seeds file skips this validation. My current solution is commenting out the validation each time I run rake db:seed. Anything a little more clever? 回答1: Have you considered adding an attribute in the model which is checked in the validate_on_create method? Example: class MyModel < ActiveRecord :: Base attr_accessor : skip_on_create_validation def validate_on

carrierwave upload Encoding::UndefinedConversionError: “\\xFF” from ASCII-8BIT to UTF-8

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Got this error on production but can't figure out where the problem is. Same request works fine on local development. But fail on production. I'm building API for mobile client use Error trace ``` Encoding::UndefinedConversionError: "\xFF" from ASCII-8BIT to UTF-8 ... 39 non-project frames File"/home/deploy/.bundler/example/ruby/2.0.0/gems/activesupport4.1.0/lib/active_support/core_ext/object/json.rb" line 34 in encode File"/home/deploy/.bundler/example/ruby/2.0.0/gems/activesupport4.1.0/lib/active_support/core_ext/object/json.rb" line 34 in

TypeError: $(…).selectize is not a function

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I installed the "selectize-rails" gem into my rails app, and I'm trying to get it to work. I keep getting this error in my web console: TypeError: $(...).selectize is not a function and nothing happens in the browser. Here's the code I have so far, following the "Email Contacts" example from this page: http://brianreavis.github.io/selectize.js/ views/emails/new.html.erb <script type="text/javascript"> $(document).ready(function() { console.log( typeof $.fn.selectize === 'function'); // true console.log( $('#select-to').length === 1 ); //

Rails 3 respond_to json, with custom attributes/methods

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In a rails app I have an action that returns a json representation of a collection of different models. It looks something like this: respond_to :json def index @cars = Car.all @vans = Van.all respond_with({ :cars => @cars, :vans => @vans }) end However, I want to customise the attributes and methods that are passed to the json object. A bit like: respond_with({ :cars => @cars.to_json(:only => [:make, :model], :methods => [:full_name]), :vans => @vans }) Doing the above, causes the json representation of the "cars" to be escaped as one big

Rails link_to method: :delete

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am sorry for asking what may be a remedial question, but in learning rails i was trying to follow along note for note in this tutorial: http://guides.rubyonrails.org/getting_started.html I posted a similar question from this tutorial last night and got a prompt response which helped me significantly, so I am hoping for the same. Thank you in advance. Section 5.14: Deleting Posts I am instructed to add a delete link to the index.html.erb page <h1>Listing Posts</h1> <table> <tr> <th>Title</th> <th>Text</th> <th></th> <th></th> <th></th> </tr