ruby-on-rails-4.1

Object stored in Rails session becomes a String?

Deadly 提交于 2019-12-22 04:16:16
问题 Normally I wouldn't store objects in a Rails session but I'm using a library that requires this. I've run into a very strange issue where a stored object appears as a String after redirect. To reproduce I've created a sample Rails 4.1 app $ rails new session-test Added a test controller: class HomeController < ApplicationController def index logger.debug "session[:customer]: #{session[:customer]}" logger.debug "session[:customer].name: #{session[:customer].name}" end def from Struct.new

Rails 4.1 AWS Beanstalk cannot find secret key base

你。 提交于 2019-12-21 05:42:56
问题 I am trying to upload my rails project on AWS Beanstalk. I've already run eb init, eb start and configured the database settings to point to RDS. After I pushed using git aws.push and waited for AWS server to be started, the link provided says: "502 Bad Gateway nginx" In the logs ------------------------------------- /var/app/support/logs/passenger.log ------------------------------------- App 6861 stderr: [ 2014-05-29 13:26:59.1308 6893/0x00000001e50050(Worker 1) utils.rb:68 ]: *** Exception

Is there a Rails 4 circular dependent: :destroy workaround?

谁说胖子不能爱 提交于 2019-12-21 03:43:15
问题 As an example for the circular dependent: :destroy issue: class User < ActiveRecord::Base has_one: :staff, dependent: :destroy end class Staff < ActiveRecord::Base belongs_to :user, dependent: :destroy end If I call user.destroy , the associated staff should be destroyed as well. Conversely, calling staff.destroy should destroy the associated user as well. This worked great in Rails 3.x, but the behavior changed in Rails 4.0 (and continues in 4.1) such that a loop forms and eventually you get

ActiveAdmin + Jquery-ui-rails 5.0.0 gem

别等时光非礼了梦想. 提交于 2019-12-14 02:30:00
问题 I'm trying to use active admin gem but when i ran bundle it says i need jquery-ui-rails version 5.0.0 so i changed my gemfile to : gem 'jquery-rails' gem 'jquery-ui-rails', '~> 5.0.0' gem 'activeadmin', github: 'gregbell/active_admin' Upon restart my server i'm getting this error in the browser File to import not found or unreadable: jquery.ui.all. Load paths: /.../.../.../.../app/assets/images /.../.../.../.../app/assets/javascripts /.../.../.../.../app/assets/stylesheets 回答1: jquery-ui

'cannot load such file — factory_girl_rails (LoadError)' in rails 4.1.8

ⅰ亾dé卋堺 提交于 2019-12-13 06:38:06
问题 While running rspec, I am getting the following error: /2.2.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- factory_girl_rails (LoadError) from /Users/radhikabhatt/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /Users/radhikabhatt/Desktop/work/cl_portalmiudla/spec/spec_helper.rb:19:in <top (required)>' from /Users/radhikabhatt/.rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb

Set SECRET_KEY_BASE in production using a .env file

此生再无相见时 提交于 2019-12-12 14:22:48
问题 I've a .env file in my root folder in production. This file defines SECRET_KEY_BASE which is used in config/secrets.yml . The problem is that I can't manage to load my .env file before my config/secrets.yml . I've tried using the dotenv gem without success. Any idea on how todo this in production? I don't want to set it globally for my webmaster user on the production server. The SECRET_KEY_BASE value should only be accessable for by application. I'm using rails 4.1. 回答1: I too use dotenv gem

Websockets with Rails(Puma) - Error during WebSocket handshake: Unexpected response code: 200

岁酱吖の 提交于 2019-12-12 03:38:57
问题 I am trying to use websocket in my Rails4.1 application Here are some relevant code snippets: Gemfile: gem 'websocket-rails' gem 'puma' development.rb config.middleware.delete Rack::Lock I am starting the server locally as: bundle exec puma -p 3000 In the chrome console I see a connection error: new WebSocketRails('localhost:3000/post/hello', true); WebSocket connection to 'ws://localhost:3000/post/hello' failed: Error during WebSocket handshake: Unexpected response code: 200 Can anyone help

rack::offline in rails 4.1 Issue

﹥>﹥吖頭↗ 提交于 2019-12-11 20:31:44
问题 can someone give me a quick solution please? I have done this: My routes: offline = Rack::Offline.configure do cache ActionController::Base.helpers.asset_path("application.css") cache ActionController::Base.helpers.asset_path("application.js") cache ActionController::Base.helpers.asset_path("jquery.min.css") cache ActionController::Base.helpers.asset_path("jquery.tmpl.min.css") cache ActionController::Base.helpers.asset_path("style.js") # cache ActionController::Base.helpers.asset_path(

NoMethodError in Sections#edit similar issue to other

天大地大妈咪最大 提交于 2019-12-11 12:41:27
问题 I am a bit new to Ruby and am writing a program from scratch... I'm getting an error and I can't figure out where it is coming from. I've spent over an hour and i'm sure it's something stupidly simple. I have other similar pages that work fine, but there's some issue with the instance variable. It's almost an identical problem as the link provided. Here's my error: Showing C:/Users/kevin/Desktop/ruby_test/sites/simple_cms/app/views/sections/_form.html.erb where line #4 raised: undefined

wrong number of arguments (1 for 0) (Social Gem )

喜欢而已 提交于 2019-12-11 08:49:33
问题 So I'm using this social gem but for some reason I'm getting the following error: wrong number of arguments (1 for 0) and this is the line of code that's causing the error: <%= tweet_button(via: "peterc", url: "http://news.ycombinator.com", :text => "AWESOME.") %> Not sure what I'm doing wrong, I've read the Documentation on the gem quite thoroughly. I've spent the last 2 weeks straight on this, with no luck.. whoever can help would be REALLY appreciated. Update; wrong number of arguments (1