ruby

Uncaught type error: $(…).datepicker() is not a function

不想你离开。 提交于 2021-02-07 18:27:52
问题 I am trying to use the jQuery datepicker function but I am receiving an error Uncaught type error: $(...).datepicker() is not a function . I have gone through my files and do not see a double reference to jQuery or incorrect file order in the application.js . Could someone help point out what might be the problem? application.html.erb <!DOCTYPE html> <html> <head> <%= javascript_include_tag 'application' %> <title>MyApp</title> <meta name="viewport" content="width=device-width, initial-scale

Ruby's && operator

可紊 提交于 2021-02-07 17:50:18
问题 In PHP, this evaluates to true : $a = 1 $b = 2 var_dump($a && $b); // true In ruby, this evaluates to 2 : a = 1 b = 2 p a && b # 2 Why does ruby return the value of the last statement (when the first is true and the second one is also true) and does not return a boolean? I have two arrays and I iterate them with an external iterator: a = [1,2,3].to_enum b = [5,6,7].to_enum c = [] begin while a_next = a.next && b_next = b.next result = a_next + b_next p "a[x] + b[x] = c[x] = #{a_next} + #{b

Ruby's && operator

天涯浪子 提交于 2021-02-07 17:47:30
问题 In PHP, this evaluates to true : $a = 1 $b = 2 var_dump($a && $b); // true In ruby, this evaluates to 2 : a = 1 b = 2 p a && b # 2 Why does ruby return the value of the last statement (when the first is true and the second one is also true) and does not return a boolean? I have two arrays and I iterate them with an external iterator: a = [1,2,3].to_enum b = [5,6,7].to_enum c = [] begin while a_next = a.next && b_next = b.next result = a_next + b_next p "a[x] + b[x] = c[x] = #{a_next} + #{b

Ruby's && operator

*爱你&永不变心* 提交于 2021-02-07 17:47:19
问题 In PHP, this evaluates to true : $a = 1 $b = 2 var_dump($a && $b); // true In ruby, this evaluates to 2 : a = 1 b = 2 p a && b # 2 Why does ruby return the value of the last statement (when the first is true and the second one is also true) and does not return a boolean? I have two arrays and I iterate them with an external iterator: a = [1,2,3].to_enum b = [5,6,7].to_enum c = [] begin while a_next = a.next && b_next = b.next result = a_next + b_next p "a[x] + b[x] = c[x] = #{a_next} + #{b

Sublime Text 3 Multiline Method Folding

断了今生、忘了曾经 提交于 2021-02-07 14:29:24
问题 SO... Sublime Text has the built in ability to fold methods, but as soon as the method declaration spans multiple lines it loses this ability. Does anyone know about a plugin or a way to make this work? Specifically I am running into this with ruby (and my team adheres to a strict style guide regarding line length), but the language shouldn't matter. 回答1: Instead of clicking on the down arrow that appears in the gutter next to the first line of the function definition, all you need to do is

Sublime Text 3 Multiline Method Folding

白昼怎懂夜的黑 提交于 2021-02-07 14:21:11
问题 SO... Sublime Text has the built in ability to fold methods, but as soon as the method declaration spans multiple lines it loses this ability. Does anyone know about a plugin or a way to make this work? Specifically I am running into this with ruby (and my team adheres to a strict style guide regarding line length), but the language shouldn't matter. 回答1: Instead of clicking on the down arrow that appears in the gutter next to the first line of the function definition, all you need to do is

In Ruby, can I check if a string contains a letter without using regular expressions?

泄露秘密 提交于 2021-02-07 13:17:25
问题 I'm using Rails 5. I want to know if a varaible (which you can assume is a String) contains at least one letter (upper case or lower case). However, I don't want to use regular expressions (I've noticed if the encoding is not UTF-8, regular expressiosn tend to crash). So I'm wondering how I can check if a string hast at least one letter. THis doesn't work input.downcase.include?("abcdefghijklmnopqrstuvwxyz") 回答1: Try this str.count("a-zA-Z") > 0 The count function accepts character sets as

In Ruby, can I check if a string contains a letter without using regular expressions?

三世轮回 提交于 2021-02-07 13:15:42
问题 I'm using Rails 5. I want to know if a varaible (which you can assume is a String) contains at least one letter (upper case or lower case). However, I don't want to use regular expressions (I've noticed if the encoding is not UTF-8, regular expressiosn tend to crash). So I'm wondering how I can check if a string hast at least one letter. THis doesn't work input.downcase.include?("abcdefghijklmnopqrstuvwxyz") 回答1: Try this str.count("a-zA-Z") > 0 The count function accepts character sets as

Nginx error: client intended to send too large body

落花浮王杯 提交于 2021-02-07 12:01:49
问题 Periodically I get an error: This site can't be reached. The webpage at https://example.com/document might be temporarily down or it my have moved permanently to are new web address. My site is stored on AWS. I use rails + nginx + passenger. Nginx error log: client intended to send too large body: 3729822 bytes, client: 172.42.35.54, server: example.com, request: "POST /document HTTP/1.1", host: "test.example.com", referrer: "https://test.example.com/document/new" app log: ActionController:

Nginx error: client intended to send too large body

老子叫甜甜 提交于 2021-02-07 12:01:10
问题 Periodically I get an error: This site can't be reached. The webpage at https://example.com/document might be temporarily down or it my have moved permanently to are new web address. My site is stored on AWS. I use rails + nginx + passenger. Nginx error log: client intended to send too large body: 3729822 bytes, client: 172.42.35.54, server: example.com, request: "POST /document HTTP/1.1", host: "test.example.com", referrer: "https://test.example.com/document/new" app log: ActionController: