similar to: Active Record: subclassing a model

Displaying 20 results from an estimated 9000 matches similar to: "Active Record: subclassing a model"

2006 Mar 29
0
Intermittent error - undefined method ''destroy_without_callbacks''
When testing my app locally I''m getting intermittent errors which are driving me mad! The error is: NameError ((eval):1:in `alias_method'': undefined method `destroy_without_callbacks'' for class `Exercise''): Refreshing the browser sometimes fixes it, as does restarting WEBrick. Annoying to debug as it only happens intermittently. Any ideas on why this is
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM relationship to the other. For example: CREATE TABLE people (id INT, name TEXT); CREATE TABLE teams (id INT, name TEXT); CREATE TABLE people_teams (person_id INT, team_id INT); The person model has: has_and_belongs_to_many :teams And the team model has: has_and_belongs_to_many :people The trouble comes when trying to destroy
2006 Mar 23
2
rails 1.1 and mysql errors
Hi, I just upgraded to rails 1.1 this morning and i am getting a variety of errors from tests that were passing effortlessly on the previous edge release (i froze several weeks ago, so I not sure what version that was). Has anyone else experienced these types errors with the new rails: I have several errors that are grouped around create and destroy commands the errors are similar, first the
2006 Jan 13
1
association callbacks
Hello all. I am looking for some feedback on an implementation. I''m writing a plugin that will log all model changes. I do not want to have to add a line a code for this functionality every time I create a model. Instead I create a table with the name <model>_changes. The basic stuff was easy: base.after_create {|model| model.log_create if model.has_backup_table?
2006 Feb 23
0
Searching within active record results - ror n00b
I am trying to set up a search page that looks within a product catalog. There are several many to many relationships with the items object. I am trying to be able to narrow searchs and then allow for text searches using tsearch2 and postgres. @format = Format.find(@params[:format_id]) @items = @format.items And then do a find_by_sql on the @items, but I know this isnt how you do this.
2005 Aug 28
1
Active Record problem
Hi all I am new to Rails, and obviously I''m missing something, I''ll get straight to the question: A User has many operations (granted to her), each Operation is associated with an OperationType. Each Operation may be associated with more then one User. So the model goes like this: class User < ActiveRecord::Base has_and_belongs_to_many :operations
2006 Apr 01
1
using find with multiple objects in active record
Hi, I am trying to learn to use RoR by making a simple social networking example. Given a user id, I am trying to make a query that finds all of the group that user belongs to but also rank the groups by one of the groups'' parameter like group.size. Pretend group.size is a number from 1-10 and is precalculated. Can I do this is one query? Here are the relationships I set up: class
2006 Jun 22
0
Active record associations
I have a table containing a person''s info: Person { first_name : string last_name : string height : int weight : int age : int } This person can belong to many leagues and 0 or 1 teams within that league. I can create join tables and use the following associations: League has_and_belongs_to_many people Team has_and_belongs_to_many people League has one
2006 Mar 12
1
alias_method interferes ApplicationHelper
Hello, I''m using Ruby 1.8.4 (darwinport), rails-1.0.0 (gem) , Powerbook / Mac OS X 10.4.5 , Webrick. How come Rails always raises NoMethodError for my helper (must_fill and rp or number_to_currency_rp) in application_helper.rb ? I doubt that alias_method is the culprit, but if i give # comment then there will be no errors at all ... :/ what am i doing wrong? is it a bug or stupid me? Thx
2006 Mar 12
1
a better way to alias methods
Hi is there a better way to accomplish this task? class PortfolioController < ProjectController layout ''portfolio'' def boing redirect_to :action=>:index end alias_method :new , :boing alias_method :destroy , :boing alias_method :edit , :boing alias_method :update , :boing end My portfolio controller implements view only
2011 Apr 16
0
adding HABTM association while creating a record
Hello Experts, I have a HABTM association as followed: class Account < ActiveRecord::Base has_and_belongs_to_many :user end class User < ActiveRecord::Base has_and_belongs_to_many :type has_and_belongs_to_many :account end class Type < ActiveRecord::Base has_and_belongs_to_many :user end I have the following query; I Have a parent user who is creating another user under its
2006 Jan 10
0
LoginGenerator called on Form Submission
I have login authentication set for the submit action of a form. I want the form to be visible to unauthenticated users but when they fill in the form and submit it, I want it to redirect to the login page and then onto the original form submission action after the user is authenticated. This part is easy. The hard part is, how do I pass the parameters collected from the original form
2005 Dec 02
8
UserEngine: stack level too deep
Hi, I''m trying to get the UserEngine running. I have installed the LoginEngine, added the essential lines to environment.rb / application.rb and application_helper.rb. Worked fine. Then I did the same with the UserEngine and when trying to set up the db: rake engine_migrate ENGINE=user I get: Migrating engine ''user_engine'' rake aborted! stack level too deep But...
2005 Sep 17
0
Reloading and redefining methods: infinite recursion
When I redefine a method like this class Klass alias_method :method_without_addition, :method def method_with_addition ... method_without_addition ... end alias_method :method, :method_with_addition end I get into trouble in the development environment. As these definitions are executed again for each request, the second time around method_without_addition is actually the
2006 Aug 14
0
ActionMailer in an infinite loop? Looks like framework bug.
I would rather post this on the dev list since it looks like only the developers can explain why this is failing. However, I can''t find where you subscribe to it! Any ideas? Here is my problem. Whenever I try to send an email I get a SystemStackError saying stack level too deep. Here is the exception trace:
2005 Dec 15
3
How to delete a record
hey, i my database i have users and groups, each user can get in different groups my db structure: table groups: id, name, basegroup, firm_id table users: id, firstname, lastname, email table groups_users: group_id, user_id my relation is a many to many: class Group < ActiveRecord::Base has_and_belongs_to_many :users end class User < ActiveRecord::Base has_and_belongs_to_many
2008 Jan 18
2
NameError when using alias_method -- but method exists?
Hello Rubyists, I am a bit stumped here. I want to extend the ''load_file'' method in the YAML module. Following along with the PickAxe example of making old methods do new things, I try this in irb: >> module YAML >> alias_method :orig_load_f, :load_file >> def load_file(*args) >> contents = orig_load_f(*args) >>
2007 Feb 26
2
undefined method ... from `alias_method'
0 wicked var/www % ./script/console Loading development environment. >> r = Recipe.find :first NameError: undefined method `recipe_type='' for class `Recipe'' from ./script/../config/../config/../app/models/recipe.rb: 101:in `alias_method'' In recipes_controller: alias_method :orig_recipe_type=, :recipe_type= def recipe_type=(t) if t.nil?
2006 Mar 14
2
no such file to load -- login_system
I''m hoping someone can help me out here. My application works fine locally using webrick. One I upload to my shared server space I get an application error saying rails has failed to start. The log file production.log reads as follows: MissingSourceFile (no such file to load -- login_system): /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__''
2006 May 27
2
NameError / active_support/dependencies
hi everyone in my dev machine, everything works flawlessly now when i uploaded my website on the server, it cannot acces User model anymore. all other pages work by the way. when i try to access User on console or by web, it shows: NameError in UsersController#signup uninitialized constant User /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:100:in