Rails

Error // Usage: rails new APP_PATH [options] // when running 'rails server'

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Background info: I'm using GIT to get a repository of a project with Ruby files in it. The project lives in my SITES folder under home directory on my Mac. I have Ruby: 1.8.7 I have just upgraded Rails to: 3.0.3 All I am trying to accomplish is to be able to render localhost.com:3000 in my browser of the GIT project I've already downloaded so I can work on it locally. I ran the command 'rails server' and was returned the message below:: Usage: rails new APP_PATH [options] Options: [--skip-gemfile] # Don't create a Gemfile -m, [--template

Recursive Rails Nested Resources

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a Rails application for project management where there are Project and Task models. A project can have many tasks, but a task can also have many tasks, ad infinitum. Using nested resources, we can have /projects/1/tasks, /projects/1/tasks/new, /projects/1/tasks/3/edit etc. However, how do you represent the recursive nature of tasks RESTfully? I don't want go another level deep, so perhaps the following would do: map.resources :tasks do |t| t.resources :tasks end That would give me the following urls: /tasks/3/tasks/new /tasks/3/tasks

Rake Test Very Slow in Windows

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why is Ruby, and Ruby on Rails (1.8.6 One Click Installer, local database) so ruddy slow on Windows? ruby script/server - 30 seconds rake test - 45 seconds etc. Yet, when I pop over to a much slower linux box, it's virtually instantaneous. I've checked everything - no significant CPU processes running, no network issues... and so on. Heck, I'd be happy with just a verbose output that at least told me where it was breaking down. Any suggestions? 回答1: In general Ruby's MRI interpreter is just not optimized for speed on windows. You might also

How can I emulate PUT/DELETE for Rails and GWT?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I would like to make my application somewhat REST compliant. I am using Rails on the backend and GWT on the frontend. I would like to do updates and deletes. I realize I can do something like mydomain.com/:id/delete (GET) and accomplish the same thing. However, as I stated previously, I would like to have a REST compliant backend. Thus, I want to do mydomain.com/:id (DELETE) and have it implicitly call my delete method. Now, it's my understanding that if a browser (my browser is GWT RequestBuilder) doesn't support DELETE/GET, Rails somehow

Why is rails trying to connect to mysql?

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have been using mysql in a new rails application, but now I wanted to give mongoDB a try so I installed mongo mapper and mongoid (to use mongo session). The installation seems to be fine because I can create mongo models. But for some reason rails is still trying to connect to mysql: Can't connect to local MySQL server . This is horrible, because even if I wasn't using mongo, rails shouldn't be trying to connect to mysql for every request. It's throwing that error even for non-existent urls. What can I do to debug this? I guess I could try

ruby 2.0 rails gem install error “cannot load such file ― openssl”

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using osx 10.8.2 installed ruby 2.0 and.... got this when trying to run "sudo gem install rails" $ sudo gem install rails ERROR: Loading command: install (LoadError) cannot load such file -- openssl ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass I had ruby 1.9.x and rails 3.2.x working alright before 回答1: You have to install OpenSSL first and recompile ruby again: RVM: rvm pkg install openssl rvm reinstall ruby-2.0.0-p0 --with-gcc=gcc-4.7 --with-openssl-dir=$rvm_path/usr 回答2: If

Ruby off the rails

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Sometimes it feels that my company is the only company in the world using Ruby but not Ruby on Rails, to the point that Rails has almost become synonymous with Ruby. I'm sure this isn't really true, but it'd be fun to hear some stories about non-Rails Ruby usage out there. 回答1: One of the huge benefits of Ruby is the ability to create DSLs very easily. Ruby allows you to create "business rules" in a natural language way that is usually easy enough for a business analyst to use. Many Ruby apps outside of web development exist for this purpose

Rails 4 pdfkit failed converting chartkick graph to pdf

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Rails 4 I followed instruction from https://github.com/pdfkit/pdfkit In controller I have respond_to do |format| format.html {render layout:'application'} format.csv {send_data @testdatares.to_csv} format.pdf { html = render_to_string(:layout => 'application' , :action => "testpage.html.erb"); kit = PDFKit.new(html); kit.stylesheets << "#{Rails.root}/app/assets/stylesheets/application.css"; send_data(kit.to_pdf, :filename => "some_name.pdf", :type => 'application/pdf') } end In application.html.erb I have <!DOCTYPE html> <html>

WKHTMLTOPDF with pdfkit on Rails ignoring table page breaks

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I know there are a lot of issues with wkhtmltopdf and page breaks that date back years, but I haven't worked out a solution yet. I'm using the PDFKit gem to generate my html pages into pdfs, but I don't want the pages to break in the middle of a table row. I'm using wkhtmltopdf-binary (0.9.9.3), which looks to be the most updated version My CSS: @media print { #scores table tr td, #scores table tr th { page-break-inside: avoid !important; } table, tr, td, th, tbody, thead, tfoot { page-break-inside: avoid !important; } } My table: <div class

Rails: named_scope, lambda and blocks

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I thought the following two were equivalent: named_scope :admin, lambda { |company_id| {:conditions => ['company_id = ?', company_id]} } named_scope :admin, lambda do |company_id| {:conditions => ['company_id = ?', company_id]} end but Ruby is complaining: ArgumentError: tried to create Proc object without a block Any ideas? 回答1: it's a parser problem. try this named_scope :admin, (lambda do |company_id| {:conditions => ['company_id = ?', company_id]} end) 回答2: I think the problem may be related to the difference in precedence between {...}