ruby-on-rails-2

what is the difference between named_scope and method?

蓝咒 提交于 2019-12-12 01:49:06
问题 named_scope or scope how difference with class method. named_scope :active, :conditions => {:status => 'Active'} def self.active self.find(:all, :conditions => {:status => 'Active'} end Whats the difference between the two? 回答1: In the end 'scope' will define a chainable class method on your model. That's why every class method, that returns a 'scope' (which is an object of the class ActiveRecord::Relation) can be used in the same way a definied scope / named_scope can. If you want to find

Rails 2.3.5 applications on Ruby 1.8.7 Rake Error.

℡╲_俬逩灬. 提交于 2019-12-11 20:43:57
问题 I am trying to install Rails 2.3 gem on my Fedora server. The application is not having Gemfile in it. It requires oauth2 gem. When I use the installation command it is giving the following error: rake aborted! can't activate rack (>= 1.1.0, < 2, runtime) for ["faraday-0.5.7", "oauth2-0.1.0"], already activated rack-1.0.1 for ["actionpack-2.3.5", "rails-2.3.5"] Is there any way to find what are the required gems for the Rails 2.3.5 gem? 来源: https://stackoverflow.com/questions/24107692/rails-2

undefined method `end_with?' for “rake aborted!”:String (NoMethodError)

大兔子大兔子 提交于 2019-12-11 18:22:40
问题 I have been facing problem running rake task/commands whenever I type rake db:migrate or rake -T, it is displaying error saying undefined method `end_with?' for "rake aborted!":String (NoMethodError).Using ruby186, rails238 and gem version 1.3.3 rake db:migrate /home/projects/.rvm/gems/ruby-1.8.6-p420@global/gems/rubygems-bundler-1.1.0/lib/rubygems-bundler/regenerate_binstubs_command.rb:48: warning: parenthesize argument(s) for future version /home/a3logics/.rvm/gems/ruby-1.8.6-p420@global

Rails application doesn't work with apache2 and passenger

心不动则不痛 提交于 2019-12-11 18:22:33
问题 Can't make my rails 2.3.5 application work correctly with apache2. In apache errors log i get the following: /usr/lib/phusion_passenger/passenger-spawn-server:53:in `require': no such file to load -- phusion_passenger/utils (LoadError) from /usr/lib/phusion_passenger/passenger-spawn-server:53 [ pid=9437 file=ext/apache2/Hooks.cpp:727 time=2012-04-02 20:04:49.923 ]: Unexpected error in mod_passenger: Cannot spawn application '/home/user/projects/pname/trunk': The spawn server has exited

Set ssl_allowed/ssl_required for all pages in Rails 2?

痴心易碎 提交于 2019-12-11 06:36:32
问题 I found that AJAX calls were not working on my Rails site when a page was using SSL/HTTPS. I worked around this by adding ssl_allowed :action1, :action2, :actionN to the controllers involved. I foresee this being a pain and prone to bugs in the future, as I'll indubitably forget to add an action to the ssl_allowed list. Is there a way to turn on ssl_allowed / ssl_required globally in the [ssl_requirement][1] gem, for all actions of every controller in my site? I tried adding the following to

expected Hash (got Array) for param 'samples'

匆匆过客 提交于 2019-12-10 12:43:30
问题 I have been following Railscasts episodes of Nested forms and complex forms. During the time of creating multiple model in a single form I was able to edit, update, delete and create records for sample models that were nested in the Batch model. I have been breaking my head from a long time and tried searching around as well but could not get any right solution for solving this problem. my development log file gives me the following error. ERROR MESSAGE: Status: 500 Internal Server Error

`add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) OR Gem.source_index is deprecated

限于喜欢 提交于 2019-12-09 13:38:23
问题 I am using rails 2.3.11, ruby-1.9.2-p320. Trying to run script/server but getting this error :- system@admin:~/apps/app_name/trunk$ script/server => Booting WEBrick => Rails 2.3.11 application starting on http://0.0.0.0:3000 /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError) from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib

Adding extra run-time attribs to an activerecord object

╄→гoц情女王★ 提交于 2019-12-08 23:39:33
问题 I have an Agent model which gets its attributes from the underlying database table. However for one particular controller action I would like to add some 'temporary' attributes to the Agent records before passing them on to the view. Is this possible? 回答1: Yes, you can extend your models on the fly. For example: # GET /agents # GET /agents.xml def index @agents = Agent.all # Here we modify the particular models in the @agents array. @agents.each do |agent| agent.class_eval do attr_accessor

Rails legacy app and Ruby 2 error: can not load translations from the file type yml is not known

ε祈祈猫儿з 提交于 2019-12-07 06:44:50
问题 I have a legacy Rails application which I want to upgrade to recent Rails and Ruby versions.To start with I am trying to setup the application with Ruby 2.1.2 $ rails -v Rails 2.3.18 $ ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux] When I tried to run the rake task rake db:schema:load RAILS_ENV=test I encountered following error can not load translations from /activesupport-2.3.18/lib/active_support/locale/en.yml, the file type yml is not known Searching through Google I found

What is the EOL (End of Life) for Rails 2.3?

我只是一个虾纸丫 提交于 2019-12-07 03:16:34
问题 What is the EOL date for Rails 2.3? 回答1: 2.3 reached EOL on 2013-06-25, when rails 4.0.0 was released. Only the "last major release series" will receive patches, according to Michael Koziarski. Therefore, when 4.0 was released, 2.3 stopped receiving patches. The rails team had hoped to drop support for 2.3 much earlier. On 2011-12-29 Aaron said: .. we have no plans of releasing another version of 2.3 [beyond 2.3.14] Before that, on 2011-06-08, Aaron said: This branch [2.3] is in security