ruby-on-rails

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

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

How to create horizontal forms with twitter bootstrap and rails simple form

烂漫一生 提交于 2021-02-20 18:51:26
问题 I am trying to create horizontal forms with simple-form and bootstrap. I have already installed bootstrap using "rails generate simple_form:install". This is what i have in html.erb <%= simple_form_for(@company, :html => { :class => "form-horizontal" }) do |f| %> <div class="form-group"> <label class="col-md-4 control-label"></label> <div class="col-md-4"> <%= f.input :name %> </div> </div> But the form still appears vertically. 回答1: simple_form is a really great gem for generating bootstrap

How to create horizontal forms with twitter bootstrap and rails simple form

☆樱花仙子☆ 提交于 2021-02-20 18:49:21
问题 I am trying to create horizontal forms with simple-form and bootstrap. I have already installed bootstrap using "rails generate simple_form:install". This is what i have in html.erb <%= simple_form_for(@company, :html => { :class => "form-horizontal" }) do |f| %> <div class="form-group"> <label class="col-md-4 control-label"></label> <div class="col-md-4"> <%= f.input :name %> </div> </div> But the form still appears vertically. 回答1: simple_form is a really great gem for generating bootstrap

Rails singleton became empty after development reload

醉酒当歌 提交于 2021-02-20 18:45:42
问题 In my rails app I've decided to use singleton to create some sort of factory to get objects properly. config/initializers/registry.rb: registry = Registry.instance registry.define_lazy :period_predictor do PeriodPredictor.new(NotificationBuilder.new, 28, 4, 3) end registry.define_lazy :notification_sender do NotificationSender.new end lib/registry.rb: # Registry class which is singleton and stores values. class Registry include Singleton # Define simple value. Like a constant. # # @param key

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

Latest omniauth-facebook gem breaks devise

拟墨画扇 提交于 2021-02-20 09:45:48
问题 ruby '2.6.3' gem 'rails', '~> 6.0.2', '>= 6.0.2.1' I'm using the latest omniauth-facebook and devise together Gemfile: gem 'devise' gem 'omniauth-facebook' Getting this error when starting the server: /versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError) The problem is that if I try to use older omniauth-facebook versions the server works but then

Latest omniauth-facebook gem breaks devise

对着背影说爱祢 提交于 2021-02-20 09:41:56
问题 ruby '2.6.3' gem 'rails', '~> 6.0.2', '>= 6.0.2.1' I'm using the latest omniauth-facebook and devise together Gemfile: gem 'devise' gem 'omniauth-facebook' Getting this error when starting the server: /versions/2.6.3/lib/ruby/gems/2.6.0/gems/devise-4.7.3/lib/devise/omniauth.rb:12:in `': You are using an old OmniAuth version, please ensure you have 1.0.0.pr2 version or later installed. (RuntimeError) The problem is that if I try to use older omniauth-facebook versions the server works but then