ruby-on-rails-2

Rails 2.3.4 Errors, :rails s && :bundle not working?

心不动则不痛 提交于 2019-12-25 01:09:54
问题 I have a friend who had an existing Rails application, which appears to be built in '2.3.4' according to the environment.rb files. He has some issues with it and asked me to look into it for him. I am used to using Rails 3.2+. I downloaded his files and ran the bundle command and got this response: Could not locate Gemfile I then tried to check out the site locally by running the rails s command. I got back: Usage: rails new APP_PATH [options] Options: -r, [--ruby=PATH] # Path to the Ruby

How to extend a model in a Rails engine from another Rails engine?

扶醉桌前 提交于 2019-12-24 16:55:06
问题 I think the simplest way to explain this is with a contrived example. I am using Rails 2.3.8 with Ruby 1.8.7 and ActiveRecord to MySQL db. I have the following (contrived) model in one engine (installed in vendor/plugins directory of main app): # contrived_app/vendor/plugins/concerts_engine/app/models/ class Concert < ActiveRecord::Base has_many :artists belongs_to :venue end And the following (contrived) model in another engine: # contrived_app/vendor/plugins/tickets_engine/app/models/ class

How do i get Rails to route to a controller instead of a static file in the public folder?

随声附和 提交于 2019-12-23 01:13:45
问题 In a Rails 2.3 app I have a SitemapController with a sitemap action that creates a human-readable sitemap page, and a route to that in the routes file. In the public folder there's a sitemap.xml file for search engines. The problem is that http://mysite/sitemap is serving up sitemap.xml , and not routing to the controller. If I delete sitemap.xml then it routes to the controller just fine. On several other very similar sites we have the exact same arrangement, but on those the existence of

Filtering parts or all of request URL from rails logs

拥有回忆 提交于 2019-12-22 09:50:12
问题 Rails provides filter_parameter_logging to filter sensitive parameters from the rails log. If you have a a JSONP API, some sensitive information could be present in the URL. Is there a way to filter request URLS from the log also? 回答1: Note : The answer here was the way to get it work on Rails 2.x ~> 3.0. Starting from Rails 3.1, if you set config.filter_parameters , Rails will filter out the sensitive parameter in the query string as well. See this commit for more detail. I think in that

Issue updating class in combobox from nested form

眉间皱痕 提交于 2019-12-22 01:31:16
问题 I created a combobox that show suppliers so when supplier is selected will update a div showing purchases , after showing purchases will be in combobox but in a nested form so when I select a purchase will show me the amount of the purchase selected. The problem is that when I select a purchase only works in the first line and when I select another combobox line show the amount of the first combobox selected. Here my tables suppliers |id| |name| 1 Supplier A 2 Supplier B shopping_documents

How to show sql result on server console

心已入冬 提交于 2019-12-21 17:18:21
问题 In Rails v2.3 , Ruby 1.8 , if I run a sql statement with following code in my model class: ActiveRecord::Base.connection.execute("select count(*) from cars;") How can I show the query result in server console? I tried : rslt = ActiveRecord::Base.connection.execute("select count(*) from cars;") p rslt but it only returns me "MySQL result object" on the server console, not the exact result. 回答1: There are couple ways to get mysql "answer" from your query. you can call each and it will iterate

Why does Rails not refresh classes on every request (despite configuration)?

懵懂的女人 提交于 2019-12-18 05:41:23
问题 I recently started having to restart my development server every time I change my code. My development.rb file still has this line: config.cache_classes = false I tried using the debugger verify that this value has stuck around. To do this I set my configuration to a global variable in environment.rb: $my_initializer = Rails::Initializer.run do |config| ... end then I put a debugger line in one of my controllers so I could do this: (rdb:2) $my_initializer.configuration.cache_classes false So

Why does Rails not refresh classes on every request (despite configuration)?

廉价感情. 提交于 2019-12-18 05:41:06
问题 I recently started having to restart my development server every time I change my code. My development.rb file still has this line: config.cache_classes = false I tried using the debugger verify that this value has stuck around. To do this I set my configuration to a global variable in environment.rb: $my_initializer = Rails::Initializer.run do |config| ... end then I put a debugger line in one of my controllers so I could do this: (rdb:2) $my_initializer.configuration.cache_classes false So

Using named_scope with counts of child models

瘦欲@ 提交于 2019-12-18 03:45:54
问题 I have a simple parent object having many children. I'm trying to figure out how to use a named scope for bringing back just parents with specific numbers of children. Is this possible? class Foo < ActiveRecord::Base has_many :bars named_scope :with_no_bars, ... # count of bars == 0 named_scope :with_one_bar, ... # count of bars == 1 named_scope :with_more_than_one_bar, ... # count of bars > 1 end class Bar < ActiveRecord::Base belongs_to :foo end I'm hoping to do something like Foo.with_one

Using named_scope with counts of child models

南楼画角 提交于 2019-12-18 03:45:25
问题 I have a simple parent object having many children. I'm trying to figure out how to use a named scope for bringing back just parents with specific numbers of children. Is this possible? class Foo < ActiveRecord::Base has_many :bars named_scope :with_no_bars, ... # count of bars == 0 named_scope :with_one_bar, ... # count of bars == 1 named_scope :with_more_than_one_bar, ... # count of bars > 1 end class Bar < ActiveRecord::Base belongs_to :foo end I'm hoping to do something like Foo.with_one