Rails

Rails 4 + Devise: Invalid route name, already in use

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm following this how-to to modify the confirmation page after a successful sign up. https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-up-(registration) I do everything like it says but i get this error: in `add_route': Invalid route name, already in use: 'new_user_session' (ArgumentError) You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes

rails generate rspec:install config/environments/development.rb:1:in `<top (required)>': undefined method `configure'

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: first, here are my versions: Greg - Nowickis - MacBook - Pro : sample_app Greg_Nowicki$ ruby - v ruby 2.0 . 0p451 ( 2014 - 02 - 24 revision 45167 ) [ x86_64 - darwin13 . 1.0 ] Greg - Nowickis - MacBook - Pro : sample_app Greg_Nowicki$ rails - v Rails 4.0 . 4 I'm following the Hartl Rails tutorial and am install rspec for testing. I have added gem 'rspec-rails' to my gemfile and when I run rails generate rspec:install, this is what I get: Greg - Nowickis - MacBook - Pro : sample_app Greg_Nowicki$ rails generate rspec : install /

Rubymine - Rails gem not found

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I installed Rails 3.2.3 and Ruby 1.9.3 going through this solution - http://ryanbigg.com/2010/12/ubuntu-ruby-rvm-rails-and-you/ . It's really amazing and effortless. There were no errors while I did this. Now I try to create a Rails project in Rubymine 4 but there's an error: "Rails version - no Rails gem found". Terminal shows me: alex@ubuntu:~$ rails -v Rails 3.2.3 alex@ubuntu:~$ ruby -v ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] alex@ubuntu:~$ UPDATE alex@ubuntu:~$ gem environment RubyGems Environment: - RUBYGEMS VERSION: 1

rails erb form helper options_for_select :selected

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an edit form in erb. Within the code I have a select with options: :gender) %> However, the select is not showing the correct selected value . What could I be doing wrong? I can get it to work if I hardcode it but of course that is not a viable option. 回答1: In your code, your options_for_select() call sets the selected value to "gender" and does not attempt to use the value from your form object. Please see the docs for options_for_select() for usage examples. options_for_select(['Mare', 'Stallion', 'Gelding'], f.object.gender)

incompatible character encodings: ASCII-8BIT and UTF-8

匿名 (未验证) 提交于 2019-12-03 01:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use Ruby 1.9.2 and Rails 3.0.5 I have the following error: incompatible character encodings: ASCII-8BIT and UTF-8 It has nothing to do with the database i think. The error is happinging on this line in a view (just a div haml call): #content full stack: ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8): 21: -flash.each do |name, msg| 22: =content_tag :div, msg, :id => "flash_#{name}" 23: %div.clear 24: #content 25: = yield 26: = render :partial => "layouts/grid_right" if render_grid_right? 27: = render

Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: When I want to create a Ruby on Rails project, I get the message below. /usr/ lib / ruby / gems / 1.8 / gems / activesupport - 2.3 . 8 / lib / active_support / dependencies . rb : 55 : uninitialized constant ActiveSupport :: Dependencies :: Mutex ( NameError ) from / usr / local / lib / site_ruby / 1.8 / rubygems / custom_require . rb : 36 : in `gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in ` require ' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support.rb:57 from /usr

Ruby on Rails - unable to convert “\\x89” from ASCII-8BIT to UTF-8 for xxx/xxxx/xxxx

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am installing ruby on rails 4.0.0 on my linux system , but i am getting this kind of errors unable to convert "\x89" from ASCII-8BIT to UTF8 for guides/assets/images/getting_started/routing_error_no_route_matches.png, skipping and many similar errors , i read here that it won't cause any effect ,but i do not understand why it is coming . Any pointers? 回答1: You need to update / install a version of the rdoc gem that supports the conversion. Then these errors won't appear during generation of the documentation when you install rails or when

How can I use unicorn as “rails s”?

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: A new rails project's gemfile shows: # Use unicorn as the app server gem 'unicorn' rails s --help shows: Usage: rails server [mongrel, thin, etc] [options] Yet, doing: rails s unicorn I get: /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler.rb:63:in `require': cannot load such file -- rack/handler/unicorn (LoadError) from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler.rb:63:in `try_require' from /Users/patrick/.rvm/gems/ruby-1.9.3-head@keynote/gems/rack-1.4.5/lib/rack/handler

How to manage Rails database.yml

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: What's the best way to handle the Rails database.yml if multiple people are working on the project and database locations are different (the socket in particular). 回答1: First, move database.yml to a template file. If you're on Git: git mv config / database . yml config / database . yml . example git commit - m "moved database.yml to an example file" Or, if you're on Subversion: svn move config / database . yml config / database . yml . example svn ci - m "moved database.yml to an example file" Second, ignore the .yml version. If

Rails - CSV(export to CSV) loop

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i want to do (export to CSV) in the form of fetching first 50 students and next 50 students and so on, in seperate files. i have tried with the below given code, and i dont know how to generate loop, please provide some code to do the process. @count =0 if @count == 0 students = Student.find(:all,:order => 'name', :limit => 50) @count = @count+1 else students = Student.find(:all,:order => 'name', :limit => 50, :offset => 50) @count = @count+1 on clicking export to csv, it should fetch 1st 50 students, next 50 students and so on in different