ruby

How to get the filename of uploaded file in rails contoller

柔情痞子 提交于 2021-02-20 19:26:30
问题 <%= file_field 'upload' %> In my controller, if I give the following, based on suggestions filename=params[:upload] @result=filename.original_filename I am getting. undefined method `original_filename' for #<ActionController::Parameters:0x002b6c396e44b8> Note: I am not using form. Rails version is 4.0.2 回答1: Use the following code in order to get the filename: params[:file].original_filename 回答2: Have you read how to upload files in Rails? Have you set your form to multipart: true ? What will

How long are nextPageTokens remembered for Gmail and Calendar APIs?

大兔子大兔子 提交于 2021-02-20 19:02:15
问题 The Gmail and Calendar APIs return a nextPageToken value in the response from the users.messages.list and events.list endpoints when pagination is required. If the value of the nextPageToken is provided in the next request to these endpoints, the next page of results is returned. My question : How long are these nextPageToken s persisted behind the Gmail and Calendar APIs? Context : I am building an abstraction on top of both the Gmail and Calendar APIs to return a list of Activities, and

While installing http_parser.rb ERROR: Failed to build gem native extension

梦想的初衷 提交于 2021-02-20 18:53:52
问题 i'm new to all of this but i get this error when i try to install http_parser using gem: dongl_000@LENNY ~/ava-home (master) $ gem install http_parser.rb -v '0.6.0' Building native extensions. This could take a while... ERROR: Error installing http_parser.rb: ERROR: Failed to build gem native extension. c:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160217-15056-1hoiyfc.rb extconf.rb creating Makefile make "DESTDIR=" clean make "DESTDIR=" generating ruby_http_parser-x64-mingw32.def make: *** No

While installing http_parser.rb ERROR: Failed to build gem native extension

折月煮酒 提交于 2021-02-20 18:53:27
问题 i'm new to all of this but i get this error when i try to install http_parser using gem: dongl_000@LENNY ~/ava-home (master) $ gem install http_parser.rb -v '0.6.0' Building native extensions. This could take a while... ERROR: Error installing http_parser.rb: ERROR: Failed to build gem native extension. c:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160217-15056-1hoiyfc.rb extconf.rb creating Makefile make "DESTDIR=" clean make "DESTDIR=" generating ruby_http_parser-x64-mingw32.def make: *** No

DelayedJob ERROR: there is already one or more instance(s) of the program running

拜拜、爱过 提交于 2021-02-20 14:12:35
问题 Some backstory: My server ran out of disk space last night while delayed_job workers were running off jobs processing images. When I try to stop the workers, I get the response "Terminated". RAILS_ENV=production script/delayed_job stop Terminated Then I run the following to see that the workers were terminated. ps -ef | grep delayed_job servername 4474 4274 0 02:37 pts/1 00:00:00 grep --color=auto delayed_job Now I try to start up new workers. RAILS_ENV=production script/delayed_job -n2 start

DelayedJob ERROR: there is already one or more instance(s) of the program running

核能气质少年 提交于 2021-02-20 14:05:21
问题 Some backstory: My server ran out of disk space last night while delayed_job workers were running off jobs processing images. When I try to stop the workers, I get the response "Terminated". RAILS_ENV=production script/delayed_job stop Terminated Then I run the following to see that the workers were terminated. ps -ef | grep delayed_job servername 4474 4274 0 02:37 pts/1 00:00:00 grep --color=auto delayed_job Now I try to start up new workers. RAILS_ENV=production script/delayed_job -n2 start

Create dynamic attribute in the Struct instance

老子叫甜甜 提交于 2021-02-20 10:12:23
问题 Is it possible to create attribute dynamicaly in the Struct instance? class Person < Struct.new(:name) end p = Person.new("Bilbo") p[:surname] = "Jenkins" # does not work 回答1: You could use an OpenStruct : require 'ostruct' p = OpenStruct.new(name: "Bilbo") p[:surname] = "Jenkins" p.surname # => "Jenkins" 回答2: You can define new methods on your Person class by doing this: Person.send(:define_method, :surname){@surname} Person.send(:define_method, :surname=){|x|@surname=x} I prefer define

How to switch bundler version?

久未见 提交于 2021-02-20 06:53:52
问题 I thought the below command would switch bundler installation, but it actually raised an error. $ bundle _1.10.6_ -v Could not find command "_1.10.6_". $ bundle -v Bundler version 1.13.6 $ gem list | grep bundle bundler (1.13.6, 1.10.6) What should I do? 回答1: To use different gem versions, you could use this pattern: your-gem _version_ . For example, bundle _1.10.6_ -v . Hope that will help. 来源: https://stackoverflow.com/questions/41500197/how-to-switch-bundler-version

How to switch bundler version?

淺唱寂寞╮ 提交于 2021-02-20 06:50:21
问题 I thought the below command would switch bundler installation, but it actually raised an error. $ bundle _1.10.6_ -v Could not find command "_1.10.6_". $ bundle -v Bundler version 1.13.6 $ gem list | grep bundle bundler (1.13.6, 1.10.6) What should I do? 回答1: To use different gem versions, you could use this pattern: your-gem _version_ . For example, bundle _1.10.6_ -v . Hope that will help. 来源: https://stackoverflow.com/questions/41500197/how-to-switch-bundler-version

Rails Sass: variables are not passed with @import

﹥>﹥吖頭↗ 提交于 2021-02-20 06:50:17
问题 I have a rails project which uses twitter bootstrap and sass. The scss files are structured into folders so I have a better overview. Now I want to define a file for global variables which contains my colors etc. and pass those values down to other files so I have less redundant code. While all code is properly imported and applied, variables don't work. Here is the current setup: stylesheets/application.css.scss /* *= require_self *= require_tree */ /* stylesheets/ | |– base/ | |– _reset