Wednesday, March 30, 2016

when force_ssl is on and I get 503 Service Unavailable: Back-end server is at capacity error after deployment | Fixed issues

Newest questions tagged ruby-on-rails - Stack Overflow

when force_ssl is on and I get 503 Service Unavailable: Back-end server is at capacity error after deployment | Fixed issues


when force_ssl is on and I get 503 Service Unavailable: Back-end server is at capacity error after deployment

Posted: 30 Mar 2016 07:40 AM PDT

I am trying to enforce ssl to be available on the entire site. This is why I have added: config.force_ssl = true config.ssl_options = {hsts: {expires: 3600}} to the application.rb file. Unfortunately after deployment I get the white screen of death. Nothing in the logs to indicate that the server is being hit, but in the network tab of the browser I see the request being made to http://staging.my_domain.com/admin and the status code: 503 Service Unavailable: Back-end server is at capacity. I checked every log that comes to mind and don't see any requests logging. I cannot figure out what is wrong. Just to clarify- before adding force_ssl = true, the website would load both on http:// and https://, so I presume that the certificate is installed correctly. Any clues? Thank you.

rails formular in bootstrap modal not processing

Posted: 30 Mar 2016 07:39 AM PDT

i've got a page movies/add

in this page I tried to use a bootstrap modal with a included form that should call the users/signup function

The form looks like this:

   <%= form_for User.new, :html => {:multipart => true, :class => "form-horizontal", :role => "form", :id => "signupform"}, :as => :user, :method => :post, :url => {}, :controller => :users, :action => :signup do |f| %>  

I don't get an error, it looks like it works fine, but in database there is nothing.

the controller function in useres_controller looks like this:

def signup  if request.post?    puts "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs"    @user = User.new(user_params)    if @user.save      flash[:notice] = t("flash.signup")      #Weiterleitung nach erfolgreichem Anlegen      redirect_to :controller => :startsites, :action => "index"    end  else    @user = User.new  end  end  

functional tests admin section rails

Posted: 30 Mar 2016 07:29 AM PDT

I have a question concerning a functional test in rails.

For the front section, the actions are only index and show

#app/controller/themes_controller_rb  class ThemesController < ApplicationController      def index      @themes = Theme.active    end      def show      @theme = Theme.find(params[:id])    end      def new    end  end  

and the test

#test/integration/theme_controller_test.rb  require 'test_helper'    class ThemesControllerTest < ActionController::TestCase      def setup      @theme = create(:theme)    end      test "should assign variable on index" do      get :index      assert_response :success      assert_not_nil assigns(:themes)    end        test "should show a theme" do      get :show, {'id' => @theme}      assert_response :success      assert_not_nil assigns(:theme)    end    end  

No problem so far

For the admin section, all the CRUD actions exists so again index and show

#app/controllers/admin/themes_controller.rb  class Admin::ThemesController < Admin::AdminController      layout 'admin/admin'    before_action :admin_user      def index      @themes = Theme.all    end      def show      @theme = Theme.find(params[:id])    end    end  

and the tests are the same

#test/controllers/admin/theme_controller_test.rb  require 'test_helper'          class Admin::ThemesControllerTest < ActionController::TestCase          def setup          @theme = create(:theme)        end          test "should assign variable on index" do          get :index          assert_response :success          assert_not_nil assigns(:themes)        end            test "should show a theme" do          get :show, {'id' => @theme}          assert_response :success          assert_not_nil assigns(:theme)        end        end  

but for those latest tests, I have a 302 response instead of succes

 FAIL["test_should_assign_variable_on_index", Admin::ThemesControllerTest, 2016-03-16 06:50:16 +0000]   test_should_assign_variable_on_index#Admin::ThemesControllerTest (1458111016.61s)          Expected response to be a <success>, but was <302>          test/controllers/admin/themes_controller_test.rb:11:in `block in <class:ThemesControllerTest>'     FAIL["test_should_show_a_theme", Admin::ThemesControllerTest, 2016-03-16 06:50:16 +0000]   test_should_show_a_theme#Admin::ThemesControllerTest (1458111016.62s)          Expected response to be a <success>, but was <302>          test/controllers/admin/themes_controller_test.rb:18:in `block in <class:ThemesControllerTest>'  

What do I do wrong ? Thanks for help :)

Rails Bundler::GemRequireError when starting server

Posted: 30 Mar 2016 07:22 AM PDT

I'm getting this error whenever I try to run the server, not sure if it has to do with the js runtime, I'm using node and execjs installed for that.

/Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'rails-api'. (Bundler::GemRequireError)  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'  from /Users/me/.rvm/gems/ruby-2.2.2@global/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'  from /Users/me/Documents/Rails/Paid/paid-api/config/application.rb:17:in `<top (required)>'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands/commands_tasks.rb:88:in `require'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands/commands_tasks.rb:88:in `block in server'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands/commands_tasks.rb:85:in `tap'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands/commands_tasks.rb:85:in `server'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands/commands_tasks.rb:49:in `run_command!'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/command.rb:20:in `run'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/railties-5.0.0.beta3/lib/rails/commands.rb:18:in `<top (required)>'  from /Users/me/Documents/Rails/Paid/paid-api/bin/rails:9:in `require'  from /Users/me/Documents/Rails/Paid/paid-api/bin/rails:9:in `<top (required)>'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `load'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `call'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/client/command.rb:7:in `call'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/client.rb:28:in `run'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/bin/spring:49:in `<top (required)>'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `load'  from /Users/me/.rvm/gems/ruby-2.2.2/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `<top (required)>'  from /Users/me/Documents/Rails/Paid/paid-api/bin/spring:13:in `require'  from /Users/me/Documents/Rails/Paid/paid-api/bin/spring:13:in `<top (required)>'  from bin/rails:3:in `load'  from bin/rails:3:in `<main>'  

My current Gemfile, pretty straight forward:

source 'https://rubygems.org'  gem 'rails', '>= 5.0.0.beta2', '< 5.1'  gem 'rails-api'  # Concurrent app server  gem 'puma'  gem 'activerecord-import', '~> 0.11.0'  # Message Queuing  gem 'aws-sdk', '~> 2'  # Load Balancing  gem 'shoryuken'  # Salesforce REST api  gem 'restforce'  # PAID ruby-gem  gem 'paid'  group :development, :test do    gem 'rubocop', '~> 0.39.0', require: false  end  group :development do    gem 'spring'  end  group :test do    gem 'rspec-core'  end  group :doc do    gem 'sdoc'  end  

My application.rb file, not much different:

require File.expand_path('../boot', __FILE__)  require "rails"  # Pick the frameworks you want:  require "active_model/railtie"  require "active_job/railtie"  # require "active_record/railtie"  require "action_controller/railtie"  require "action_mailer/railtie"  require "action_view/railtie"  require "action_cable/engine"  # require "sprockets/railtie"  require "rails/test_unit/railtie"  # Require the gems listed in Gemfile, including any gems  # you've limited to :test, :development, or :production.  Bundler.require(*Rails.groups)  module PaidApi    class Application < Rails::Application      config.active_job.queue_adapter = :shoryuken    end  end  

Ruby on Rails - Unable to create a new profile for each user.

Posted: 30 Mar 2016 07:14 AM PDT

I'm building an events app with users who will each have a personal profile. I've set up a few users for the site but when I try and create and/or edit a profile for each user it refers me back to a flash message "That profile doesn't belong to you!" which is in reference to my first user profile which was set up and works fine.

I'm using Devise gem for initial set up but have built out from their with my own user controller. Here's the code from that controller -

class UsersController < ApplicationController before_action :authenticate_user! before_action :set_user before_action :owned_profile, only: [:edit, :update]

def new      @user = User.new  end      def show      @user = User.find(params[:id])    end    def create  end    #def edit      #@user = User.find(params[:id])  

No comments:

Post a Comment