Rails

rails server cannot start; getaddrinfo: nodename nor servname provided, or not known (SocketError)

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have not found a solution to the problem, however someone did already ask about the same problem a few days ago - ( Rails Server Keeps Exiting (SocketError) ) After I start a rails server the system returns some error I cannot understand. To install Ruby on Rails on my mac I did everything as listed on http://railsapps.github.io/installrubyonrails-mac.html here is my terminal response: $ rails server => Booting WEBrick => Rails 4.2.0 application starting in development on http://localhost:3000 => Run `rails server -h` for more startup

How do I install rails on a Windows machine that uses a proxy server to get to the internet?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm a big fan of the ruby way. However today it got in my way. The defacto way of installing rails (i'm running as a domain user on a WinXP machine) is download and install ruby (one-click installer) type >gem install rails at the command prompt Step 2 fails with some function getaddrhost not able to function. Some googling taught me that this is a known issue - See Authenticating Windows Proxy Problems on the rubygems FAQ The suggested options there to "use the -p or --http-proxy http://proxy:port " switch for gem install also didn't work

rails encryption/decryption

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i need to do encryption and decryption in my rails app. Im trying to use ezcrypto, but whenever i do decryption i get this error. OpenSSL::Cipher::CipherError in ProfilesController#show wrong final block length What would need to be changed to stop this error. I tried using another implementation of openssl like this (methods to be called from my model) def encrypt_attr(unencrypted) c = OpenSSL::Cipher.new("aes-256-cbc") c.encrypt c.key = Digest::SHA1.hexdigest('pass') e = c.update(unencrypted) e << c.final return e end def decrypt_attr

In rails is it possible to get colour highlighting for the rake test command?

匿名 (未验证) 提交于 2019-12-03 02:52:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When running the rake test command from the terminal within a rails 3 project directory, the test result output is not coloured. Hence it cannot be interpreted at a glance. Is there a way of getting colourised output for the results, as you can get in rspec? >rspec --colour 回答1: Yes, you can use the redgreen gem. Include it in your gemfile: group :development, :test do gem 'redgreen' end And that's all you need for ruby 1.8. If you're using 1.9, there's a workaround. add the test-unit gem: group :development, :test do gem 'redgreen' gem

Rails ActiveRecord: Locking down attributes when record enters a particular state

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Wondering if there’s a plugin or best way of setting up an ActiveRecord class so that, for example, when a record enter the "published" state, certain attributes are frozen so that they could not be tampered with. 回答1: You can freeze an entire AR::B object by setting @readonly to true (in a method), but that will lock out all attributes. The way I would recommend is by defining attribute setter methods that check for the current state before passing to super: class Post < ActiveRecord::Base def author=(author) super unless self.published?

Rails i18n: Can I turn off “translation missing” errors?

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a multi-tenant application and I'm experimenting with using the i18n gem to allow each of our clients to customize the system to their liking, changing the text on various pages, customizing emails, and so forth. Admittedly, I'm not using i18n as it was intended to be used, since I'm not actually translating different "languages", everything is in English, but each client has a DIFFERENT English, if that makes sense. Still, I've come across what I think is a horribly bad design decision in the i18n gem: if ever a translation does not

Rails implementation for securing S3 documents

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to protect my s3 documents behind by rails app such that if I go to: www.myapp.com/attachment/5 that should authenticate the user prior to displaying/downloading the document. I have read similar questions on stackoverflow but I'm not sure I've seen any good conclusions. From what I have read there are several things you can do to "protect" your S3 documents. 1) Obfuscate the URL. I have done this. I think this is a good thing to do so no one can guess the URL. For example it would be easy to "walk" the URL's if your S3 URLs are

Uninstall Rails 3 with dependencies?

匿名 (未验证) 提交于 2019-12-03 02:51:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I like that Rails 3 is so easy to install: gem install rails --pre , and all of the dependencies are automatically installed for you. But, what about uninstalling it? If I just do gem uninstall rails , I still have actionmailer (3.0.0.beta3) actionpack (3.0.0.beta3) activemodel (3.0.0.beta3) activerecord (3.0.0.beta3) activeresource (3.0.0.beta3) activesupport (3.0.0.beta3) which I want to get rid of. What's the easiest way to do so? 回答1: if you're planning to upgrade to a newer version of rails, you can do: sudo gem clean or in newer

Weird rails error “permission denied: bin/rails” for old rails apps

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm getting this error whenever I run rails (or any rails command) _rails_command:2: permission denied: bin/rails ONLY when i'm inside some old rails app directory. In these directories bundle exec rails c command works but rails or even rails -v don't work. Background: I keep my coding workspace in dropbox folder. Now I recently installed Manjaro and hence all the rails apps which I downloaded back from my previous OS I call them old rails app. In Short: Rails works fine everywhere except for old rails apps. bundle exec rails c

Rails console in production: NameError: uninitialized constant

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a rails app (rails 5). In development, everything work, when i use rails console And enter an instruction, for example User.all , it's working. In production, my app work perfectly, no problems, no errors, but when i use rails console production and enter for example User.all i have an error : NameError: uninitialized constant User from (irb):2 from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start' from /home/alexandre/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0