Rails

rails install - ERROR … executing gem … (OpenSSL::SSL::SSLError) SSL_connect … read server hello A: wrong version number

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am very new to Linux (been living in MS world for many years). I thought I'd try something different, like ruby on rails under linux. Been trying to get a dev machine set up, and I must say, it's been quite overwhelming! Here is what I have done so far, and my current problem that I cannot figure out: Installed Linux Mint 15 (was this a bad choice? the only reason I ask is all the difficulties I've had so far) Ran the update manager and installed all updates. Install git sudo apt-get install git Install rbenv git clone https://github.com

add a database column with Rails migration and populate it based on another column

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm writing a migration to add a column to a table. The value of the column is dependent on the value of two more existing columns. What is the best/fastest way to do this? Currently I have this but not sure if it's the best way since the groups table is can be very large. class AddColorToGroup < ActiveRecord :: Migration def self . up add_column : groups , : color , : string Groups = Group . all . each do | g | c = "red" if g . is_active && is_live c = "green" if g . is_active c = "orange" g . update_attribute (: type , c ) end

SASS Invalid CSS error on Rails

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to use http://startbootstrap.com/stylish-portfolio in my rails app however I'm getting the following error in my stylish-portfolio.css.scss.erb file: ActionView::Template::Error (Invalid CSS after "body ": expected selector or at-rule, was "{" This is my css file: @import 'bootstrap' /* Global Styles */ html, body { height: 100%; width: 100%; } .vert-text { display: table-cell; vertical-align: middle; text-align: center; } .vert-text h1 { padding: 0; margin: 0; font-size: 4.5em; font-weight: 700; } ... 回答1: My guess is that you

Ruby on Rails: Treat deprecation warnings as errors or otherwise find deprecated code?

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I recently upgraded from Rails 2 to Rails 3, and I'm trying to root out all the code I might have that is deprecated. The way I'm doing this is just surfing around a copy of my site running on a development machine, and peering at the output from the console for warnings. Is there a way to cause Rails to treat deprecation warnings as errors or otherwise find deprecated code more efficiently? 回答1: You can customise the behaviour of deprecated calls by setting ActiveSupport::Deprecation.behavior . This should be set to a Proc that accepts a

RubyMine error: Unable to run gem &#039;rails&#039;. Cannot find &#039;rails&#039;

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When I try to create Rails Application with RubyMine, it fails with message "Unable to run gem 'rails'. Cannot find 'rails'". Why? And how to solve it? RubyMine's version is 4.0.2. There's some information about my system: $ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux] $ gem -v 1.8.11 $ uname -a Linux somehost 3.2.0-2-amd64 #1 SMP Tue Mar 20 18:36:37 UTC 2012 x86_64 GNU/Linux $ lsb_release -d Description: Debian GNU/Linux testing (wheezy) $ rails -v Rails 3.2.3 Here's output of gem list --local: http://pastebin.com

Ruby on Rails 3 howto make &#039;OR&#039; condition

匿名 (未验证) 提交于 2019-12-03 03:05:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need an SQL statement that check if one condition is satisfied: SELECT * FROM my_table WHERE my_table.x=1 OR my_table.y=1 I want to do this the 'Rails 3' way. I was looking for something like: Account.where(:id => 1).or.where(:id => 2) I know that I can always fallback to sql or a conditions string. However, in my experience this often leads to chaos when combining scopes. What is the best way to do this? Another related question, is how can describe relationship that depends on an OR condition. The only way I found: has_many :my_thing,

Rails server does not start -&gt; Could not find a JavaScript runtime [duplicate]

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: execJs: 'Could not find a JavaScript runtime' but execjs AND therubyracer are in Gemfile 20 answers I created a new rails app in folder 'issues' and when I wanted to 'ruby s' I got an error. Any help will be much appreciated [thiago@netbox issues]$ rails s /home/thiago/.rvm/gems/ruby-1.9.3-p429/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable) from

rails and bootstrap: Uncaught ReferenceError: jQuery is not defined

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I created a simple webapp integrating bootstrap 3 in a rails 3.2.17 application, following this procedure found on stackoverflow, so without using a gem but manually copying the bootstrap files in the relevant app directories. Even if i have, in my gem file: gem 'jquery-rails' i can still see, inspecting my web page with chrome, the error: Uncaught ReferenceError: jQuery is not defined My page is a "normal" html page in public directory. Maybe it doesn't "inherit" all the assets stuff? The code is like this: <!DOCTYPE html> <html> <head>

Rails 3 / Devise: Password salt no longer being created?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been working on a project for a while now which uses Devise for user authentication. Whenever a user was created, it would generate a password salt for them along with their encrypted password. As I'm coming to the tail end of this project, I was testing user registration and noticed that my new roles were not creating a password salt in the database for these new users, whereas my older users all had salts. The new users can sign in fine, yet I'm concerned why Devise is no longer creating salts. The only oddity with Devise I

What is the replacement for ActionController::Base.relative_url_root?

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am porting a 2.x rails app to rails3; we'll call it foo-app. Foo-app is one section of a larger rails app and lives at main_rails_app.com/foo-app. Previously we just set up the following in our foo-app production config to ensure that our foo-app routes worked properly: ActionController :: Base . relative_url_root = "/foo-app" However, with rails3, I now get: DEPRECATION WARNING : ActionController :: Base . relative_url_root is ineffective . Please stop using it . I have since changed the config entry to the following: config .