Guruza search results for activerecord http://guruza.com/searches/show/353 Questions recently submitted to Guruza that match the query: activerecord Thu, 20 Nov 2008 13:45:48 -0800 $1.00 - Ruby / Ruby on Rails: I am building a database wrapper in a class. I want... http://guruza.com/question/483/reward-1.00 Ruby / Ruby on Rails: I am building a database wrapper in a class. I want to expose a string array of people (ex: ['john','jane','lucie']) which basically wraps a comma-delimited string column in a legacy database (names are in the db as: 'john,jane,lucie'). I'd like to be able to do: foo.people[1] = 'mark', foo.people.pop or even foo.people.push('richard') and have the changes reflected in the database. How do I hook into an array to be able to perform the underlying database operations? I'm not quite sure how to implement this correctly. Mon, 15 Jan 2007 10:40:57 -0800 $0.00 - I am trying to use sqlite3 for my dev database with my Rails app (1.2rc2). I... http://guruza.com/question/482/reward-0.00 I am trying to use sqlite3 for my dev database with my Rails app (1.2rc2). I am on OS X so sqlite3 is installed by default (I even installed the lastest version with darwinport), and I have done gem install sqlite3-ruby. However, when I try to do anything that has to do with ActiveRecord, I get errors. Here's an example: >> Domain.new ActiveRecord::StatementInvalid: ActiveRecord::StatementInvalid from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/connection_adapters/sqlite_adapter.rb:273:in `table_structure' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.3.1.5848/lib/active_support/core_ext/object/misc.rb:23:in `returning' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/connection_adapters/sqlite_adapter.rb:272:in `table_structure' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/connection_adapters/sqlite_adapter.rb:210:in `columns' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/base.rb:760:in `columns' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/base.rb:2048:in `attributes_from_column_definition_without_lock' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/locking/optimistic.rb:45:in `attributes_from_column_definition' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/base.rb:1490:in `initialize_without_callbacks' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4.5848/lib/active_record/callbacks.rb:225:in `initialize' from (irb):1 Any idea? EDIT: The funny thing is that I use sqlite3 and it works great with another project I started some time ago... Mon, 15 Jan 2007 07:58:30 -0800 $10.00 - Is there any way I can use find_by_sql AND eager load associations? I have t... http://guruza.com/question/393/reward-10.00 Is there any way I can use find_by_sql AND eager load associations? I have to return everything in 1 sql statement, but I would still like to access associations normally when outputting in my rhtml file. Mon, 11 Sep 2006 16:58:34 -0700 $0.00 - I am new to ruby on rails and doing a simple application as I am studying rub... http://guruza.com/question/368/reward-0.00 I am new to ruby on rails and doing a simple application as I am studying ruby on rails. I have a m:n relationship between people and languages ... a person can know many langs and a lang can be known by many people ... I want to give a GUI in which there are 2 lists of languages for a person to edit 1 with the languages he knows 2 other languages .. I want to allow him to add & remove languages ie shift from one list to the other list Eg: if person1 has english and french in the database , the lists would look like List1: english french List2: spanish italian german etc etc etc... [ plz note: they are side by side ] and he can double click or do something to select a lang in list2 and add it to list1 and vice versa... I thought it would be a good excerise to learn ruby but I am struck .. I wanted to know if there is any helper class available for this kinda feature... Can someone suggest me as to how I can do this efficiently in ruby.. [ I currently have a string which has all languages seperated by comma and the user can modify the string.. I parse the string @ the controller and store it into the database.. ] Thu, 31 Aug 2006 21:12:38 -0700 $3.00 - how to get validates_presence_of to work with non-null float/boolean/integer ... http://guruza.com/question/323/reward-3.00 how to get validates_presence_of to work with non-null float/boolean/integer fields? Has anyone figured out a way to get validates_presence_of to work with float, boolean, and integer fields that are defined as non-null in the schema? The problem is, rails intializes these types to the default schema value, which for mysql is never null if the column is not allowed to be null, and as a result they are initialized in the form with a value, and are never null. I found a work around for integers that requires a nasty method override in the ActiveRecord class that sets the default values from the database, but I can not find a solution to do the same for floats because ruby will not let me assign a float to null once it has been initialized with a value. Wed, 16 Aug 2006 16:33:19 -0700 $5.00 - Validating Multiple Models The problem is that when I use error_messages_f... http://guruza.com/question/321/reward-5.00 Validating Multiple Models The problem is that when I use error_messages_for to display validation errors for two models, only the parent model's validation is displayed and not for the relationships. Example. class Resource < ActiveRecord::Base has_one :setting end class Setting < ActiveRecord::Base belongs_to :resource end If I do: @resource = Resource.new @resource.settings = Settings.new @resource.save! Only Resource's validation shows up and not Setting's. Is there anyway that I can validate the relationships of a model? *ANSWER* "if model1.valid? and model2.valid? and model3.valid? save model data" Wed, 16 Aug 2006 11:14:30 -0700 $4.00 - Is there a rails equivalence to out.flush() in java? I have an activerecord r... http://guruza.com/question/301/reward-4.00 Is there a rails equivalence to out.flush() in java? I have an activerecord resultset that is quite large. However I don't want to wait till the query is done to display all of the results. I would like to display the results as they come in. I need someway to flush the outputstream so that it constantly writes the results to the browser. Is this possible? Tue, 08 Aug 2006 08:21:48 -0700 $0.00 - Hi, I am getting a bit flamed over at (http://gregluck.com/blog) for makin... http://guruza.com/question/269/reward-0.00 Hi, I am getting a bit flamed over at (http://gregluck.com/blog) for making some possibly inaccurate comments about Rails caching. Where is there a clear statement of Rails' ActiveRecord caching abilities? I found some info on cached_model. Greg Wed, 26 Jul 2006 09:50:30 -0700 $10.00 - I would like to display the full error message for some errors, but only the ... http://guruza.com/question/251/reward-10.00 I would like to display the full error message for some errors, but only the :message component for others. Is there any way to specify this? <%= errors_messages_for 'foo' %> validates_presence_of :bar, :message => 'Bad Bar!' validates_presence_of :foo, :message => 'is missing' Should output: There were problems with the following fields: Bad Bar! Foo is missing Wed, 19 Jul 2006 14:23:56 -0700 $10.00 - Can someone please help with this odd error? It appears that rails is not pa... http://guruza.com/question/245/reward-10.00 Can someone please help with this odd error? It appears that rails is not parsing the url correctly. However, browsing to the url http://guruza.com/question/244/0.0/523#comment_537 does not replicate the error A ActiveRecord::StatementInvalid occurred in question#index: PGError: ERROR: invalid input syntax for integer: "523#comment_537" : SELECT * FROM conversations WHERE (conversations."id" = '523#comment_537' ) LIMIT 1 /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log' ------------------------------- Request: ------------------------------- * URL: http://guruza.com/question/244/0.0/523#comment_537 * Parameters: {"action"=>"index", "reward"=>"0.0", "conversation_id"=>"523#comment_537", "id"=>"244", "controller"=>"question"} * Rails root: /var/www/guruza ------------------------------- Session: ------------------------------- * @write_lock: true * @session_id: **HIDDEN** * @new_session: false * @data: {:request_data=> {:request_uri=>"/question/244/0.0/523#comment_537", :raw_post=>nil}, "flash"=>{}} ------------------------------- Environment: ------------------------------- * DOCUMENT_ROOT : **HIDDEN** * FCGI_ROLE : RESPONDER * GATEWAY_INTERFACE : CGI/1.1 * HTTP_ACCEPT : text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 * HTTP_ACCEPT_CHARSET : ISO-8859-1,utf-8;q=0.7,*;q=0.7 * HTTP_ACCEPT_ENCODING: gzip * HTTP_ACCEPT_LANGUAGE: es * HTTP_COOKIE : **HIDDEN** * HTTP_HOST : guruza.com * HTTP_REFERER : http://guruza.com/ * HTTP_USER_AGENT : Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.0.4) Gecko/20060508 Firefox/1.5.0.4 * HTTP_X_FORWARDED_FOR: 83.41.203.33 * HTTP_X_MOZ : prefetch * PATH_INFO : * QUERY_STRING : * REDIRECT_STATUS : 200 * REDIRECT_URI : /dispatch.fcgi * REMOTE_ADDR : **HIDDEN** * REMOTE_PORT : 48682 * REQUEST_METHOD : GET * REQUEST_URI : /question/244/0.0/523#comment_537 * SCRIPT_FILENAME : /var/www/guruza/public/dispatch.fcgi * SCRIPT_NAME : /dispatch.fcgi * SERVER_ADDR : 66.220.26.12 * SERVER_NAME : guruza.com * SERVER_PORT : 80 * SERVER_PROTOCOL : HTTP/1.1 * SERVER_SOFTWARE : lighttpd/1.4.10 * Process: 15875 * Server : ------------------------------- Backtrace: ------------------------------- /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in `log' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/postgresql_adapter.rb:148:in `execute' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/postgresql_adapter.rb:362:in `select' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/postgresql_adapter.rb:129:in `select_all' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in `find_by_sql' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in `find_every' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:918:in `find_initial' /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1103:in `method_missing' [RAILS_ROOT]/app/controllers/question_controller.rb:21:in `index' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_with_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_with_benchmark' /usr/lib/ruby/1.8/benchmark.rb:293:in `measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_with_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action_with_rescue' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_with_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process_with_session_management_support' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:150:in `process_request' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:54:in `process!' /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/fcgi.rb:600:in `each_cgi' /usr/lib/ruby/gems/1.8/gems/fcgi-0.8.6.1/fcgi.rb:597:in `each_cgi' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:53:in `process!' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/fcgi_handler.rb:23:in `process!' [RAILS_ROOT]/public/dispatch.fcgi:24 Sun, 16 Jul 2006 15:09:06 -0700 $3.00 - I'm creating a very simple Rails app that will become my online phone book. ... http://guruza.com/question/230/reward-3.00 I'm creating a very simple Rails app that will become my online phone book. I just want to scaffold the whole thing as much as possible since I don't need anything fancy. I have a People table, and a Phone_Numbers table in my db. Phone_Numbers has a person_id field. Here's my Person class: class Person < ActiveRecord::Base has_many :phone_numbers end and my PhoneNumber class: class PhoneNumber < ActiveRecord::Base belongs_to :person end However, when I run the scaffolding, I cannot add/edit phone numbers when I edit a Person. Is this normal? I thought scaffolding would do this automatically, but maybe I was expecting too much from this. Thanks! Sat, 08 Jul 2006 17:21:10 -0700 $5.00 - Whats the best way of handling invalid records when using Rails find method? http://guruza.com/question/143/reward-5.00 Whats the best way of handling invalid records when using Rails find method? Thu, 29 Jun 2006 19:00:02 -0700 $0.00 - webapp dev with rails http://guruza.com/question/117/reward-0.00 webapp dev with rails Mon, 26 Jun 2006 09:10:12 -0700 $5.00 - Miguel Can you help me debug chat? http://guruza.com/question/85/reward-5.00 Miguel Can you help me debug chat? Wed, 07 Jun 2006 13:56:46 -0700