ruby-on-rails-2

Failing to access environment variables within `database.yml` file

倾然丶 夕夏残阳落幕 提交于 2019-12-17 15:22:12
问题 I have the following developement section of my development.yml file: development: adapter: postgresql host: localhost database: testtb username: app_user password: ENV['APP_USER_POSTGRES_PASSWORD'] <= Troublesome line When I open a rails console via bundle exec rails console and type ENV['APP_USER_POSTGRES_PASSWORD'] I get back the DB password I've specified in my local profile. However, when I start my rails server, it can't connect to the DB, failing with PGError FATAL: password

Rails 2: Model.find(1) gives ActiveRecord error when id 1 does not exist

蓝咒 提交于 2019-12-17 06:12:33
问题 I am using Rails 2.3.5 and in that if I give Model.find(1) and if 1 is not in the database, it returns ActiveRecord error. Should it just be returning nil as in the case of Model.find_by_column('..') ? 回答1: This is the expected behavior. I think David explains this the best himself, so here is a quote from Ruby, S., Thomas, D. & Hansson, D.H., 2009. Agile Web Development with Rails, Third Edition Third Edition., Pragmatic Bookshelf (p.330). When you use a finder driven by primary keys, you’re

Rails 2: Model.find(1) gives ActiveRecord error when id 1 does not exist

大城市里の小女人 提交于 2019-12-17 06:12:10
问题 I am using Rails 2.3.5 and in that if I give Model.find(1) and if 1 is not in the database, it returns ActiveRecord error. Should it just be returning nil as in the case of Model.find_by_column('..') ? 回答1: This is the expected behavior. I think David explains this the best himself, so here is a quote from Ruby, S., Thomas, D. & Hansson, D.H., 2009. Agile Web Development with Rails, Third Edition Third Edition., Pragmatic Bookshelf (p.330). When you use a finder driven by primary keys, you’re

Issue having blank graphic in Highchart script

自古美人都是妖i 提交于 2019-12-13 05:31:52
问题 I followed steps from http://www.highcharts.com/demo/column-basic/skies and the issue is that my values from my controller to my Highchart graphic is showing blank ( is not showing my value) Here my tables http://sqlfiddle.com/#!2/b7347/5 that i use in my controller |policies| ID POLICY_NUM DATE_INI CATEGORY_ID 1 1234 2013-01-10 1 2 5678 2013-01-10 2 3 3444 2013-02-10 1 4 4577 2013-02-10 2 |categories| ID NAME 1 Life 2 Vehicles Here is my controller def report @jan_life =Policy.find_by_sql(

undefined method `deliver_sent' for MailerFormError:Class

﹥>﹥吖頭↗ 提交于 2019-12-13 04:26:27
问题 I'm upgrading rais 2.3.2 project to rails 3 Error: undefined method `deliver_sent' for MailerFormError:Class Application Trace | Framework Trace | Full Trace app/controllers/leads_controller.rb:72:in `block in create' app/controllers/leads_controller.rb:56:in `create' MailerFormError is my model: class MailerFormError < ActionMailer::Base It's no method 'deliver_sent' in model and Actionmailer::Base too :( code with it in controller: @msg = {} @msg["errors"] = @lead.errors @msg["params"] =

Why is my rake call causing an 'undefined method `source_index`' error?

江枫思渺然 提交于 2019-12-12 13:49:54
问题 I am trying to run bundle exec rake db:migrate then encountered the following error. bundle exec rake db:migrate --trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `source_index' for Gem:Module C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:298:in `add_gem_load_paths' C:/Ruby193/lib/ruby

Throw an exception whenever someone tries to mass-assign protected attributes

Deadly 提交于 2019-12-12 08:36:17
问题 I'm fixing some mass assignment vulnerabilities in a client's application and I want to make sure Rails isn't silently dropping attempts to mass assign protected attributes. Instead, I want to throw an exception so I can investigate. I.e., whenever this would normally appear in the logs: WARNING: Can't mass-assign these protected attributes: ... I'd like to throw an exception instead (or in addition) Edit: I'm using Rails 2.3.4 回答1: You'll have to do some Rails monkey-patching to do this. Be

Collect xml response by third party web service

怎甘沉沦 提交于 2019-12-12 05:31:14
问题 I have used this command to send xml files to a web service named SRA-ENA. submission_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.submission.xml"), 'SUBMISSION') study_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.study.xml"), 'STUDY') sample_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.sample.xml"), 'SAMPLE') run_field = Curl::PostField.content(File.read("xml/#{@experiment.alias}.run.xml"), 'RUN') experiment_field = Curl:

ActiveRecord::StatementInvalid: ArgumentError: negative string size (or size too big): SELECT * FROM [shop]

独自空忆成欢 提交于 2019-12-12 03:13:10
问题 I'm getting this error when trying to instantiate too much objects in memory. This a Rails 2.3.x app, with SQL Server as the database. >> Shop.count => 14111 >> Shop.all ActiveRecord::StatementInvalid: ArgumentError: negative string size (or size too big): SELECT * FROM [shop] from /Users/lunks/.rvm/gems/ree-1.8.7-2011.03@ums/gems/activerecord-2.3.14/ lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log' from /Users/lunks/.rvm/ gems/ree-1.8.7-2011.03@ums/gems/activerecord

Rails splited code not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 02:54:43
问题 I am using rails 2.3. In my application it uses val = Party.find(:all, :conditions => [" type in ('Physician') || id in (?)",PartyLabel.find(:all,:conditions=>"label_id=#{Label.find_by_label("Can Schedule").id}").collect{|p| p.party_id if Party.find(p.party_id).respond_to?("provider_organizations")}], :with_disabled => true).select{|physician| not physician.provider_organizations.blank? }.collect{|enum| [enum.display_name_schedule, enum.id]} code to achieve some requirements. Now i wants to