ruby-on-rails-4

ActiveAdmin Batch Action Dynamic Form

霸气de小男生 提交于 2020-01-13 11:04:47
问题 I am using rails 4 with ActiveAdmin. I created a batch action using a custom form to create a Task with a Build number for every selected Device. Here's what my code looks like: ActiveAdmin.register Device do def get_builds builds = [] Build.all.each do |build| builds << [ "[#{build.resource} - #{build.version}] #{build.file_name}", build.id ] end return builds end batch_action :create_task, form: { build: get_builds() } do |ids, inputs| build = Build.find(inputs[:build]) Device.where(id: ids

Rails 4.2.0.beta2 - Can't connect to LocalHost?

半城伤御伤魂 提交于 2020-01-13 10:29:16
问题 I installed Rails 4.2.0.beta2 per the instructions in RailsTutorial.org 3rd Edition (the one that just came out). I'm not using the cloudIDE and am instead using Ubuntu Trusty 32 via Vagrant on a Windows 7 host with RVM. Did rails _4.2.0.beta2_ new hello_app and then pasted in his gemfile sample. After that, I ran: $ bundle install $ rails s Server starts fine, however when I try to connect to localhost:3000 I get "Server Not Found" Weirder still, I have a couple other Rails starter projects

`require': No such file to load — test_helper (LoadError)

此生再无相见时 提交于 2020-01-13 09:56:06
问题 I get the following error when I run my Rails application in production mode, but when I run my app in development mode it works fine. Can I use any gems in production mode? `require': No such file to load -- test_helper (LoadError) The following is the full trace of the code: /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require': No such file to load -- test_helper (LoadError) from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems

`require': No such file to load — test_helper (LoadError)

做~自己de王妃 提交于 2020-01-13 09:55:07
问题 I get the following error when I run my Rails application in production mode, but when I run my app in development mode it works fine. Can I use any gems in production mode? `require': No such file to load -- test_helper (LoadError) The following is the full trace of the code: /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require': No such file to load -- test_helper (LoadError) from /home/nyros/.rvm/gems/ruby-2.2.0@dfl/gems

Warning: input is a void element tag and must not have `children` or use `props.dangerouslySetInnerHTML`. Check the render method of null

柔情痞子 提交于 2020-01-13 09:30:08
问题 I am trying to render the errors in the form if the ajax call to the form URL fails. Below is my Admin component: #app/assets/javascripts/components/admin.js.coffee @Admin = React.createClass # propTypes: -> # emailVal: React.PropTypes.string.isRequired getInitialState: -> edit: false errorTexts: [] handleToggle: (e) -> e.preventDefault() @setState edit: !@state.edit @setState errorTexts: [] handleDelete: (e) -> e.preventDefault() # yeah... jQuery doesn't have a $.delete shortcut method $

Push to Heroku fails: Could not find net-ssh-2.10.0 in any of the sources. Failed to install gems via Bundler

ε祈祈猫儿з 提交于 2020-01-13 09:19:33
问题 I tried pushing my app to heroku but get the following error: remote: -----> Using Ruby version: ruby-2.2.2 remote: -----> Installing dependencies using 1.9.7 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: Fetching gem metadata from https://rubygems.org/........... remote: Fetching version metadata from https://rubygems.org/... remote: Fetching dependency metadata from https://rubygems.org/.. remote: Could

Convert Rails 4 has_many from condition with proc to where

主宰稳场 提交于 2020-01-13 09:17:29
问题 I have the following working has_many with a proc to capture a parameter for context: has_many :subclass_point_analytics, :conditions => proc {"assessment_id = #{self.send(:assessment_id)}" }, :foreign_key => 'gid', :dependent => :destroy I am using Rails 4 and it is (rightfully) complaining about use of :conditions. After 30 minutes and lots of tries I cannot figure out how to convert :conditions to -> { where ... } format. I would appreciate someone with knowledge of proc syntax to help me

How to find failed jobs list in sidekiq?

末鹿安然 提交于 2020-01-13 08:33:28
问题 I am using sidekiq in rails4 . How can I find failed jobs list and reprocesses them to perform in sidekiq ? 回答1: See Sidekiq::RetrySet in sidekiq/api https://github.com/mperham/sidekiq/wiki/API#retries 回答2: Try sidekiq-failures , I believe that is what you want. https://github.com/mhfs/sidekiq-failures 来源: https://stackoverflow.com/questions/23608052/how-to-find-failed-jobs-list-in-sidekiq

Rails 4 API deployment example to Amazon EC2 using Capistrano 3, Nginx, Puma, GitHub, and RVM?

南笙酒味 提交于 2020-01-13 08:31:47
问题 I have a Rails 4 API project on GitHub, and I'm trying to deploy it from my MacBook Pro using Capistrano 3 to two Amazon AWS EC2 Ubuntu instances using SSH keys - one is the app/web server, and the other is the PostgreSQL database server. The app/web server has the latest Ruby 2 via RVM, and will serve the API with Nginx / Puma . Nginx will host multiple sites, one of which is this API. These are the relevant gems I'm using: gem 'capistrano', '~> 3.0.0' gem 'capistrano-rails' gem 'capistrano

Best practice in making Rails applications multilingual

佐手、 提交于 2020-01-13 08:10:09
问题 Hello everyone :D I've just started learning Rails and currently I have one concern. I am building a Rails web site which needs to be translated to 4 languages. What would be the most practical and convenient method to do it? I've read the main goal would be to make separate folders for each language and copy all the views for each language. But I would still have notice messages on English inside my controller so how would I handle that. Routes are also my concern. Should I have 4 different