Hi everyone,
I have a Transaction for a batch insert/update block and all of sudden it stopped working.
The are no errors or exception risen and it seems like Rails stops just before the end of the Transaction blog so the methods does not return.
I restarted both MySQL and the system but still.
...
Hi
I am trying to delete list of albums from Album table. Following is the syntax but it fails saying "Lambda Parameter not in scope"
Album.Delete(x => (ListOfIds).Contains(x.Id));
What am I missing here?
Please advise.
Thanks
Pankaj
...
What advantages and disadvantages do you know of Ruby on Rails polymorphic relationships.
...
Hi,
I'm having a problem with validation in my RoR Model:
def save
self.accessed = Time.now.to_s
self.modified = accessed
validate_username
super
end
def validate_username
if User.find(:first, :select => :id, :conditions => ["userid = '#{self.userid}'"])
self.errors.add(:userid, "already exists")
end
end
As you ca...
Hello all! I've got the following models:
project.rb
has_many :tasks
task.rb
belongs_to :project
has_many :assignments
has_many :users, :through => :assignments
user.rb
has_many :assignments
has_many :tasks, :through => :assignments
assignment.rb
belongs_to :task
belongs_to :user
So for example:
Project.first.title #=> "Manh...
shepherd has_many animals. I am trying to clone one of them:
dolly=shepherd.animals.build(sheep.clone)
I get error:
undefined method `stringify_keys!' for #<Sheep:0xb6ce154c>
why? what is another way to clone dolly so that she would be associated with a shepherd and have sheep's attributes?
...
Id like to create a model in rails that does not correlate to a table in the database. Instead the model should dynamically pull aggregrate data about other models.
Example:
I have a Restaurant model stored in the restaurants table in the DB. Id like to have a RestaurantStats model where i can run a RestaurantStats.find_total_visitors...
I really like these two patterns.
The drawback of Repository pattern is its cost(takes more time then Active record). Benefit is higher abstraction which really helps on complicated business logic.
The drawback of Active record is that lower testability(db interaction is required) and harder in handling complicated domain logic.
Is it...
My understanding of the has_many relationship in Rails is that it will use a JOIN to find related rows. If I were implementing this from scratch I would have created a relational table. Am I correct in thinking it will be slower to use a JOIN? In Django, I believe the relational tables are created, and I know that I can use a relational ...
Hi,
could you tell me plz - how to write tests for projects, which uses in model establish_connection to connect another database?
...
I've add a custom sort to an ActiveRecord model by defining a method like this:
class MyClass < ActiveRecord::Base
belongs_to :parent_model #this would be the many in a has_many relationship
def <=>(other)
self.att <=> other.att
end
end
Suffice it to say, the logic actually being employed in the comparison is a bit more com...
I want to implement a messaging system for my app.
I have users.
What exactly should I do?
create a messages model with foreign two user foreign keys??.. what would be the most approproate way of getting this done?
My worry is that if I query "message.user" I wont know if Id be getting the sender of the receiver of the message
...
Hi
I am trying to select count of rows from a table which has foreign keys of two tables. The C# code threw the error mentioned below. So, I added a primary key column to the table (schema as follows) and regenerated the code. But still the same error is coming.
Error : Can't decide which property to consider the Key - you can create o...
Hi guys,
This is the scenario : Upon invoking the ActiveRecordBase<t>.Save
(entity) I want to execute the ActiveRecordBase<t>.FindAll() method.
The new inserted record could not get the details on the child class
while the other record can. This was happened everytime I inserted a
new record. I'm just wondering what is wrong.
let say h...
This is probably quite simple but I haven't yet been able to wrap my head around the problem.
I have 3 tables... (well more than that) but in this scenario 3 that matter.
Places
Bookings and
Ratings
Places has_many bookings
Each booking has_one rating (because the user only rates once) and belongs_to (a) Place
Ratings belong_to (a) ...
Can this be done? In a single application, that manages many projects with SQLite.
What I want is to have a different database for each project my app is managing.. so multiple copies of an identically structured database, but with different data in them. I'll be choosing which copy to use base on params on the URI.
This is done for 1. ...
I have a project which needs to use an agregrate function to sort and return relevant records from one of my active record models. Problem is, despite seeing it used on numerous rails tutorials, and despite it being in the online ActiveRecord documentation, my Rails app throws this error at me when the method is called:
Unknown key(s):...
I have an old MonoRail/ActiveRecord I've been doing some work too.
Recently I decided to upgrade the application to Castle Trunk & NHibernate 2.1.0.4000 GA and I'm now finding a few issues with running tests:
First off - When using TestDriven.Net to run the integration tests that work against the database, it's crashing TestDriven.Net ...
hiya
when deleteing this works:
orderitems.Delete(x => x.orderitem_sessionid == transkey);
however this does not work
orderitem.Delete(x => x.orderitem_sessionid == transkey
&& x.orderitem_productid == 6);
i get no errors, but nothing is deleted either, i have working code as a substitute of
var Deleteable...
I can't figure out why rails has_one :through associations don't accept assignments. Here is the error:
>> u = User.new
=> #<User id: nil, created_at: nil, updated_at: nil>
>> u.primary_account
=> nil
>> u.primary_account = Account.new
NoMethodError: undefined method `update_attributes' for #<Class:0x1035ce5f0>
from /Library/Ruby/Ge...